mirror of
https://github.com/plankanban/planka.git
synced 2025-12-17 09:13:23 +03:00
Add username to user
This commit is contained in:
18
server/api/helpers/get-user-by-email-or-username.js
Normal file
18
server/api/helpers/get-user-by-email-or-username.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user