feat: fix issues in invite user.

feat: fix update last login at after login.
This commit is contained in:
Ahmed Bouhuolia
2020-09-05 22:18:53 +02:00
parent d35b124178
commit 750377ba86
16 changed files with 535 additions and 336 deletions

View File

@@ -2,6 +2,7 @@ import { Service, Inject, Container } from "typedi";
import JWT from 'jsonwebtoken';
import uniqid from 'uniqid';
import { omit } from 'lodash';
import moment from "moment";
import {
EventDispatcher,
EventDispatcherInterface,
@@ -76,6 +77,11 @@ export default class AuthenticationService {
this.logger.info('[login] generating JWT token.');
const token = this.generateToken(user);
this.logger.info('[login] updating user last login at.');
await SystemUser.query()
.where('id', user.id)
.patch({ last_login_at: moment().toMySqlDateTime() });
this.logger.info('[login] Logging success.', { user, token });
// Triggers `onLogin` event.