fix(auth): unify scheme creator display
This commit is contained in:
@@ -146,6 +146,7 @@ const App = (props: React.PropsWithChildren<AppProps>) => {
|
||||
const { user } = data;
|
||||
return {
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
name: user.name,
|
||||
avatar: user.image,
|
||||
};
|
||||
|
||||
@@ -66,6 +66,7 @@ const authOptions: NextAuthOptions = {
|
||||
profile(profile) {
|
||||
return {
|
||||
id: profile.sub,
|
||||
username: profile.preferred_username,
|
||||
name: profile.name ?? profile.preferred_username,
|
||||
email: profile.email,
|
||||
image: Avatar.src,
|
||||
@@ -79,6 +80,12 @@ const authOptions: NextAuthOptions = {
|
||||
if (profile?.sub) {
|
||||
token.sub = profile.sub;
|
||||
}
|
||||
const preferredUsername = (
|
||||
profile as { preferred_username?: unknown } | undefined
|
||||
)?.preferred_username;
|
||||
if (typeof preferredUsername === "string") {
|
||||
token.username = preferredUsername;
|
||||
}
|
||||
|
||||
if (account) {
|
||||
if (account.access_token) {
|
||||
@@ -104,6 +111,9 @@ const authOptions: NextAuthOptions = {
|
||||
if (session.user && token.sub) {
|
||||
session.user.id = token.sub;
|
||||
}
|
||||
if (session.user && token.username) {
|
||||
session.user.username = token.username;
|
||||
}
|
||||
if (token.accessToken) {
|
||||
session.accessToken = token.accessToken;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user