mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Fix things for MySQL
This commit is contained in:
@@ -4,8 +4,9 @@ import argon2 from 'argon2';
|
||||
import { nanoid } from 'nanoid';
|
||||
import ms from 'ms';
|
||||
import { InvalidCredentialsException } from '../exceptions';
|
||||
import { Session, Accountability, AbstractServiceOptions } from '../types';
|
||||
import { Session, Accountability, AbstractServiceOptions, Action } from '../types';
|
||||
import Knex from 'knex';
|
||||
import ActivityService from '../services/activity';
|
||||
|
||||
type AuthenticateOptions = {
|
||||
email: string;
|
||||
@@ -17,10 +18,12 @@ type AuthenticateOptions = {
|
||||
export default class AuthenticationService {
|
||||
knex: Knex;
|
||||
accountability: Accountability | null;
|
||||
activityService: ActivityService;
|
||||
|
||||
constructor(options?: AbstractServiceOptions) {
|
||||
this.knex = options?.knex || database;
|
||||
this.accountability = options?.accountability || null;
|
||||
this.activityService = new ActivityService();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,6 +75,17 @@ export default class AuthenticationService {
|
||||
user_agent: userAgent,
|
||||
});
|
||||
|
||||
if (this.accountability) {
|
||||
await this.activityService.create({
|
||||
action: Action.AUTHENTICATE,
|
||||
action_by: user.id,
|
||||
ip: this.accountability.ip,
|
||||
user_agent: this.accountability.userAgent,
|
||||
collection: 'directus_users',
|
||||
item: user.id,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
accessToken,
|
||||
refreshToken,
|
||||
|
||||
Reference in New Issue
Block a user