Add auth starter
This commit is contained in:
43
ui/server/api/auth/[...].ts
Normal file
43
ui/server/api/auth/[...].ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import {NuxtAuthHandler} from '#auth'
|
||||
|
||||
export default NuxtAuthHandler({
|
||||
secret: "my-cool-secret",
|
||||
providers: [
|
||||
{
|
||||
id: "default",
|
||||
name: "default",
|
||||
type: "oauth",
|
||||
wellKnown: "",
|
||||
clientId: "",
|
||||
clientSecret: "",
|
||||
authorization: {
|
||||
params: {
|
||||
scope: "openid email profile"
|
||||
}
|
||||
},
|
||||
idToken: true,
|
||||
// checks: [ "pkce", "state" ],
|
||||
profile(profile) {
|
||||
return {
|
||||
id: profile.sub,
|
||||
name: profile.name,
|
||||
email: profile.email,
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
callbacks: {
|
||||
async jwt({ token, account }) {
|
||||
// Persist the access token to the token right after signin
|
||||
if (account) {
|
||||
token.accessToken = account.access_token;
|
||||
}
|
||||
return token;
|
||||
},
|
||||
async session({ session, token }) {
|
||||
// Send properties to the client
|
||||
session.accessToken = token.accessToken;
|
||||
return session;
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user