mirror of
https://codeberg.org/MarkusThielker/next-ory.git
synced 2025-04-10 11:58:41 +00:00
fix: build bug due to invalid session use
This commit is contained in:
parent
38488d71e8
commit
12f61cfea9
4 changed files with 19 additions and 8346 deletions
1
authentication/.gitignore
vendored
1
authentication/.gitignore
vendored
|
@ -12,6 +12,7 @@
|
|||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
public/sw.js
|
||||
|
||||
# production
|
||||
/build
|
||||
|
|
8335
authentication/package-lock.json
generated
8335
authentication/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -23,15 +23,16 @@
|
|||
"@serwist/next": "^9.0.0-preview.21",
|
||||
"@serwist/precaching": "^9.0.0-preview.21",
|
||||
"@serwist/sw": "^9.0.0-preview.21",
|
||||
"axios": "^1.7.9",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "^2.1.0",
|
||||
"lucide-react": "^0.460.0",
|
||||
"next": "15.0.3",
|
||||
"next-themes": "^0.4.3",
|
||||
"oslo": "^1.1.3",
|
||||
"react": "19.0.0-rc-66855b96-20241106",
|
||||
"react-dom": "19.0.0-rc-66855b96-20241106",
|
||||
"react-hook-form": "^7.51.0",
|
||||
"serwist": "^9.0.11",
|
||||
"sharp": "^0.33.4",
|
||||
"sonner": "^1.4.3",
|
||||
"tailwind-merge": "^2.2.1",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
'use client';
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Session, SessionDevice } from '@ory/client';
|
||||
import { Card, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { UAParser } from 'ua-parser-js';
|
||||
import { IResult, UAParser } from 'ua-parser-js';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
|
||||
|
@ -14,17 +14,21 @@ interface SessionItemProps {
|
|||
}
|
||||
|
||||
export default function SessionItem({ session, showInvalidate, invalidateSession }: SessionItemProps) {
|
||||
const [result, setResult] = useState<IResult | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!session.devices || session.devices.length < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
const device = session.devices[0]
|
||||
|
||||
if (!session.devices || session.devices.length < 1) {
|
||||
return;
|
||||
}
|
||||
const parser = new UAParser(device.user_agent);
|
||||
setResult(parser.getResult());
|
||||
|
||||
const [device] = useState<SessionDevice>(session.devices[0]);
|
||||
}, [setResult, session])
|
||||
|
||||
const parser = new UAParser(device.user_agent);
|
||||
const result = parser.getResult();
|
||||
|
||||
return (
|
||||
return result ? (
|
||||
<Card className="relative w-full">
|
||||
<CardHeader>
|
||||
<CardTitle>
|
||||
|
@ -49,5 +53,7 @@ export default function SessionItem({ session, showInvalidate, invalidateSession
|
|||
</Badge>
|
||||
}
|
||||
</Card>
|
||||
) : (
|
||||
<div>Loading...</div>
|
||||
);
|
||||
}
|
Loading…
Add table
Reference in a new issue