#6434 - SignIn issue_improve-signInLogMethod #1848

Closed
jsegarra wants to merge 65 commits from 6434-improve-signInLog into test
2 changed files with 8 additions and 7 deletions
Showing only changes of commit 66bf95975a - Show all commits

View File

@ -49,13 +49,7 @@ module.exports = Self => {
if (vnUser.twoFactor)
throw new ForbiddenError(null, 'REQUIRES_2FA');
}
const validateLogin = await Self.validateLogin(user, password);
await Self.app.models.SignInLog.create({
token: validateLogin.token,
userFk: vnUser.id,
ip: ctx.req.ip
});
return validateLogin;
return Self.validateLogin(user, password);
};
Self.passExpired = async vnUser => {

View File

@ -126,6 +126,7 @@ module.exports = function(Self) {
});
Self.signInValidate = (user, userToken) => {
const [[key, value]] = Object.entries(Self.userUses(user));
if (userToken[key].toLowerCase() !== value.toLowerCase()) {
console.error('ERROR!!! - Signin with other user', userToken, user);
throw new UserError('Try again');
@ -137,6 +138,12 @@ module.exports = function(Self) {
const token = await Self.login(loginInfo, 'user');
const userToken = await token.user.get();
await Self.app.models.SignInLog.create({
jsegarra marked this conversation as resolved Outdated
Outdated
Review

Pq el = null? sino el pases seria undefined que tame te val no?

Pq el = null? sino el pases seria undefined que tame te val no?
token: token.id,
userFk: userToken.id,
ip: ctx.req.ip
});
Self.signInValidate(user, userToken);
try {