Skip to content
This repository has been archived by the owner on Dec 25, 2024. It is now read-only.

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
walnuts1018 committed Oct 31, 2023
1 parent 1f42d36 commit 0b43bc9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 62 deletions.
53 changes: 0 additions & 53 deletions front/src/app/api/auth/[...nextauth]/route.ts

This file was deleted.

30 changes: 21 additions & 9 deletions front/src/app/api/auth/[...nextauth]/route.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import NextAuth from "next-auth";
import { JWT } from "next-auth/jwt";
import ZitadelProvider from "next-auth/providers/zitadel";
import { custom } from 'openid-client';
import { custom } from "openid-client";

var client_id = process.env.ZITADEL_CLIENT_ID;
var client_secret = process.env.ZITADEL_CLIENT_SECRET;
var zitadel_url = process.env.ZITADEL_URL;
const client_id = process.env.ZITADEL_CLIENT_ID;
const client_secret = process.env.ZITADEL_CLIENT_SECRET;
const zitadel_url = process.env.ZITADEL_URL;

if (!client_id || !client_secret) {
throw new Error("ZITADEL_CLIENT_ID and ZITADEL_CLIENT_SECRET must be set");
Expand All @@ -24,19 +24,31 @@ const authOptions = {
}),
],
callbacks: {
jwt: async ({ token, user, account, profile, isNewUser }: { token: JWT, user?: any, account?: any, profile?: any, isNewUser?: boolean }) => {
jwt: async ({
token,
user,
account,
profile,
isNewUser,
}: {
token: JWT;
user?: any;
account?: any;
profile?: any;
isNewUser?: boolean;
}) => {
if (user) {
token.user = user;
const u = user as any
const u = user as any;
token.role = u.role;
}
if (account) {
token.accessToken = account.access_token
token.accessToken = account.access_token;
}
return token;
},
session: ({ session, token }: { token: JWT, session?: any }) => {
token.accessToken
session: ({ session, token }: { token: JWT; session?: any }) => {
token.accessToken;
return {
...session,
user: {
Expand Down

0 comments on commit 0b43bc9

Please sign in to comment.