Skip to content

Commit 2477a30

Browse files
committed
add misssing awaits and wrap in try/catch so
invalid usernames doesnt crash nodebb @julianlam
1 parent e8a50c5 commit 2477a30

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

library.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,22 @@ OAuth.loadStrategies = async (strategies) => {
9393
if (![id, displayName, email].every(Boolean)) {
9494
return done(new Error('insufficient-scope'));
9595
}
96-
97-
const user = await OAuth.login({
98-
name,
99-
oAuthid: id,
100-
handle: displayName,
101-
email,
102-
});
103-
104-
winston.verbose(`[plugin/sso-oauth2-multiple] Successful login to uid ${user.uid} via ${name} (remote id ${id})`);
105-
authenticationController.onSuccessfulLogin(req, user.uid);
106-
OAuth.assignGroups({ provider: name, user, profile });
107-
done(null, user);
108-
109-
plugins.hooks.fire('action:oauth2.login', { name, user, profile });
96+
try {
97+
const user = await OAuth.login({
98+
name,
99+
oAuthid: id,
100+
handle: displayName,
101+
email,
102+
});
103+
winston.verbose(`[plugin/sso-oauth2-multiple] Successful login to uid ${user.uid} via ${name} (remote id ${id})`);
104+
await authenticationController.onSuccessfulLogin(req, user.uid);
105+
await OAuth.assignGroups({ provider: name, user, profile });
106+
done(null, user);
107+
108+
plugins.hooks.fire('action:oauth2.login', { name, user, profile });
109+
} catch (err) {
110+
done(err);
111+
}
110112
}));
111113

112114
configs.forEach((strategy, idx) => {

0 commit comments

Comments
 (0)