mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
WIP pass the failed tests.
This commit is contained in:
@@ -7,6 +7,7 @@ import Mustache from 'mustache';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { pick } from 'lodash';
|
||||
import uniqid from 'uniqid';
|
||||
import moment from 'moment';
|
||||
import Logger from '@/services/Logger';
|
||||
import asyncMiddleware from '@/http/middleware/asyncMiddleware';
|
||||
import SystemUser from '@/system/models/SystemUser';
|
||||
@@ -19,6 +20,7 @@ import TenantsManager from '@/system/TenantsManager';
|
||||
import TenantModel from '@/models/TenantModel';
|
||||
import PasswordReset from '@/system/models/PasswordReset';
|
||||
|
||||
|
||||
export default {
|
||||
/**
|
||||
* Constructor method.
|
||||
@@ -51,7 +53,7 @@ export default {
|
||||
login: {
|
||||
validation: [
|
||||
check('crediential').exists().isEmail(),
|
||||
check('password').exists().isLength({ min: 4 }),
|
||||
check('password').exists().isLength({ min: 5 }),
|
||||
],
|
||||
async handler(req, res) {
|
||||
const validationErrors = validationResult(req);
|
||||
@@ -87,7 +89,17 @@ export default {
|
||||
errors: [{ type: 'USER_INACTIVE', code: 110 }],
|
||||
});
|
||||
}
|
||||
// user.update({ last_login_at: new Date() });
|
||||
const lastLoginAt = moment().format('YYYY/MM/DD HH:mm:ss');
|
||||
|
||||
const updateTenantUser = TenantUser.tenant().query()
|
||||
.where('id', user.id)
|
||||
.update({ last_login_at: lastLoginAt });
|
||||
|
||||
const updateSystemUser = SystemUser.query()
|
||||
.where('id', user.id)
|
||||
.update({ last_login_at: lastLoginAt });
|
||||
|
||||
await Promise.all([updateTenantUser, updateSystemUser]);
|
||||
|
||||
const token = jwt.sign(
|
||||
{ email: user.email, _id: user.id },
|
||||
|
||||
Reference in New Issue
Block a user