Skip to content

Commit

Permalink
feat: adding user email to auth state (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
aversini authored Sep 1, 2024
1 parent 74132e6 commit 6bd0ca3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/auth-provider/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const GRAPHQL_QUERIES = {
refreshToken,
userId,
username,
email
}
}`,
};
3 changes: 3 additions & 0 deletions packages/auth-provider/src/common/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type AuthState = {
user?: {
userId?: string;
username?: string;
email?: string;
};
debug?: boolean;
authenticationType: typeof AUTH_TYPES.PASSKEY | typeof AUTH_TYPES.CODE;
Expand All @@ -73,6 +74,7 @@ export type AuthenticateUserResponse =
accessToken: string;
refreshToken: string;
userId: string;
email: string;
status: true;
}
| {
Expand Down Expand Up @@ -136,6 +138,7 @@ export type InternalActions =
user: {
userId: string;
username: string;
email: string;
};
};
}
Expand Down
1 change: 1 addition & 0 deletions packages/auth-provider/src/common/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export const loginUser = async ({
accessToken: response.data.accessToken,
refreshToken: response.data.refreshToken,
userId: jwt.payload[JWT.USER_ID_KEY] as string,
email: jwt.payload[JWT.EMAIL_KEY] as string,
status: true,
};
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const AuthProvider = ({
user: {
userId: jwt.payload[JWT.USER_ID_KEY] as string,
username: jwt.payload[JWT.USERNAME_KEY] as string,
email: jwt.payload[JWT.EMAIL_KEY] as string,
},
},
});
Expand Down Expand Up @@ -248,6 +249,7 @@ export const AuthProvider = ({
user: {
userId: response.userId as string,
username,
email: response.email as string,
},
},
});
Expand Down Expand Up @@ -446,6 +448,7 @@ export const AuthProvider = ({
user: {
userId: response.data.userId as string,
username: response.data.username as string,
email: response.data.email as string,
},
},
});
Expand Down

0 comments on commit 6bd0ca3

Please sign in to comment.