1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00
planka/server/api/helpers/get-user-by-email-or-username.js
2020-04-03 00:35:25 +05:00

18 lines
376 B
JavaScript

module.exports = {
inputs: {
emailOrUsername: {
type: 'string',
required: true,
},
},
async fn(inputs, exits) {
const fieldName = inputs.emailOrUsername.includes('@') ? 'email' : 'username';
const user = await sails.helpers.getUser({
[fieldName]: inputs.emailOrUsername.toLowerCase(),
});
return exits.success(user);
},
};