uibee 1.6.1 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  import { NextResponse } from 'next/server';
2
2
  import type { AuthTokenProps } from 'uibee/utils';
3
- export default function AuthToken({ request, frontendURL }: AuthTokenProps): Promise<NextResponse<unknown>>;
3
+ export default function AuthToken({ req, frontendURL, redirectPath }: AuthTokenProps): Promise<NextResponse<unknown>>;
@@ -1,13 +1,13 @@
1
1
  import { NextResponse } from 'next/server';
2
- export default async function AuthToken({ request, frontendURL }) {
3
- const url = new URL(request.url);
2
+ export default async function AuthToken({ req, frontendURL, redirectPath }) {
3
+ const url = new URL(req.url);
4
4
  const token = url.searchParams.get('access_token');
5
5
  const btg = url.searchParams.get('btg');
6
6
  if (!token) {
7
7
  return NextResponse.json({ error: 'No access token provided' }, { status: 400 });
8
8
  }
9
9
  if (btg) {
10
- return NextResponse.redirect(new URL('/dashboard', frontendURL));
10
+ return NextResponse.redirect(new URL(redirectPath || '/', frontendURL));
11
11
  }
12
12
  const accessToken = url.searchParams.get('access_token');
13
13
  const accessTokenExpires = url.searchParams.get('access_token_expires');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uibee",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "Shared components, functions and hooks for reuse across Login projects",
5
5
  "homepage": "https://github.com/Login-Linjeforening-for-IT/uibee#readme",
6
6
  "bugs": {
@@ -48,8 +48,9 @@ declare module 'uibee/utils' {
48
48
  }
49
49
 
50
50
  export interface AuthTokenProps {
51
- request: NextRequest
51
+ req: NextRequest
52
52
  frontendURL: string
53
+ redirectPath?: string
53
54
  }
54
55
  export interface AuthLogoutProps {
55
56
  request: NextRequest
@@ -1,8 +1,8 @@
1
1
  import { NextResponse } from 'next/server'
2
2
  import type { AuthTokenProps } from 'uibee/utils'
3
3
 
4
- export default async function AuthToken({ request, frontendURL }: AuthTokenProps) {
5
- const url = new URL(request.url)
4
+ export default async function AuthToken({ req, frontendURL, redirectPath }: AuthTokenProps) {
5
+ const url = new URL(req.url)
6
6
  const token = url.searchParams.get('access_token')
7
7
  const btg = url.searchParams.get('btg')
8
8
  if (!token) {
@@ -10,7 +10,7 @@ export default async function AuthToken({ request, frontendURL }: AuthTokenProps
10
10
  }
11
11
 
12
12
  if (btg) {
13
- return NextResponse.redirect(new URL('/dashboard', frontendURL))
13
+ return NextResponse.redirect(new URL(redirectPath || '/', frontendURL))
14
14
  }
15
15
 
16
16
  const accessToken = url.searchParams.get('access_token')!