Skip to content

Commit

Permalink
add logic for 1st time login with Microsoft (#349)
Browse files Browse the repository at this point in the history
create new account if first time logging in via Microsoft OAuth feature

Co-authored-by: Joseph Richardson <richardson.joseph1990@gmail.com>
  • Loading branch information
jerrycyip and JMStudiosJoe authored Oct 19, 2023
1 parent 2baf1d5 commit 7bd4263
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backend/graphql_api/graphql/resolvers/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,13 @@ module.exports = (logger) => {
try {
user = await authentication.verifyMicrosoftToken(dbClient, context.token);
if (!user.isRegistered) {
logger.error(`User not registered`);
throw new Error(`User not registered`);
// Create new user if first time signing in w/ Microsoft
user = await mutationResolver.createAccount(
dbClient,
{ email_address: user.email_address },
context
);
return { token: user.token, email: user.email_address };
}
token = authentication.createJWT({ rows: [user] });
} catch (e) {
Expand Down

0 comments on commit 7bd4263

Please sign in to comment.