1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00
planka/server/api/helpers/users/get-one-by-email-or-username.js

17 lines
329 B
JavaScript
Raw Normal View History

2020-04-03 00:35:25 +05:00
module.exports = {
inputs: {
emailOrUsername: {
type: 'string',
required: true,
},
},
async fn(inputs) {
2020-04-03 00:35:25 +05:00
const fieldName = inputs.emailOrUsername.includes('@') ? 'email' : 'username';
return sails.helpers.users.getOne({
2020-04-03 00:35:25 +05:00
[fieldName]: inputs.emailOrUsername.toLowerCase(),
});
},
};