Created
December 15, 2017 05:21
-
-
Save zbarbuto/3b8daca7ef43731a3d040c26ed8b80e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const loopback = require('loopback'); | |
module.exports = function(app) { | |
app.model( | |
loopback.Model.extend( | |
'LoginCredentials', | |
{ | |
id: false, | |
username: 'string', | |
password: 'string' | |
}, | |
{ forceId: false, idInjection: false } | |
) | |
); | |
updateLoginMethod(app); | |
}; | |
function updateLoginMethod(app) { | |
const login = app.models.User.sharedClass | |
.methods() | |
.find(item => item.name === 'login'); | |
Object.assign(login, { | |
accepts: [ | |
{ | |
arg: 'credentials', | |
type: 'LoginCredentials', | |
required: true, | |
http: { source: 'body' } | |
} | |
], | |
returns: [{ type: 'AccessToken', root: true }] | |
}); | |
app.emit('modelRemoted'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment