refs #6434 feat: show error for wrong login
This commit is contained in:
parent
e0f6d08a1e
commit
0a31968cc7
|
@ -2,6 +2,7 @@ const vnModel = require('vn-loopback/common/models/vn-model');
|
||||||
const {Email} = require('vn-print');
|
const {Email} = require('vn-print');
|
||||||
const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
vnModel(Self);
|
vnModel(Self);
|
||||||
|
@ -125,10 +126,16 @@ module.exports = function(Self) {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.validateLogin = async function(user, password) {
|
Self.validateLogin = async function(user, password) {
|
||||||
let loginInfo = Object.assign({password}, Self.userUses(user));
|
const loginInfo = Object.assign({password}, Self.userUses(user));
|
||||||
token = await Self.login(loginInfo, 'user');
|
const token = await Self.login(loginInfo, 'user');
|
||||||
|
|
||||||
const userToken = await token.user.get();
|
const userToken = await token.user.get();
|
||||||
|
|
||||||
|
if (userToken.username !== user) {
|
||||||
|
console.error('ERROR!!! - Signin with other user', userToken, user);
|
||||||
|
throw new UserError('Try again');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Self.app.models.Account.sync(userToken.name, password);
|
await Self.app.models.Account.sync(userToken.name, password);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue