1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00

ref: Refactoring

This commit is contained in:
Maksim Eltyshev 2023-10-19 16:05:34 +02:00
parent 9011ee61da
commit 0fab6075bd
23 changed files with 96 additions and 91 deletions

View file

@ -11,7 +11,7 @@ module.exports = {
},
exits: {
invalidToken: {},
invalidCodeOrNonce: {},
missingValues: {},
emailAlreadyInUse: {},
usernameAlreadyInUse: {},
@ -23,14 +23,14 @@ module.exports = {
let userInfo;
try {
const tokenSet = await client.callback(
`${sails.config.custom.baseUrl}/oidc-callback`,
sails.config.custom.oidcRedirectUri,
{ code: inputs.code },
{ nonce: inputs.nonce },
);
userInfo = await client.userinfo(tokenSet);
} catch (e) {
sails.log.warn(`Error while exchanging OIDC code: ${e}`);
throw 'invalidToken';
throw 'invalidCodeOrNonce';
}
if (!userInfo.email || !userInfo.name) {
@ -73,7 +73,7 @@ module.exports = {
} else {
// If no IDP/User mapping exists, search for the user by email.
user = await sails.helpers.users.getOne({
email: values.email,
email: values.email.toLowerCase(),
});
// Otherwise, create a new user.