mirror of
https://github.com/directus/directus.git
synced 2026-02-15 01:45:51 -05: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,
|
||||
|
||||
@@ -42,14 +42,10 @@ export default class FieldsService {
|
||||
fields = (await this.service.readByQuery({})) as Field[];
|
||||
}
|
||||
|
||||
const fieldsQuery = this.knex.select('*').from('directus_fields');
|
||||
|
||||
if (collection) {
|
||||
fieldsQuery.where({ collection });
|
||||
}
|
||||
|
||||
const columns = await schemaInspector.columnInfo(collection);
|
||||
|
||||
console.log(columns);
|
||||
|
||||
return columns.map((column) => {
|
||||
const field = fields.find(
|
||||
(field) => field.field === column.name && field.collection === column.table
|
||||
|
||||
@@ -48,6 +48,7 @@ export default class ItemsService implements AbstractService {
|
||||
accountability: this.accountability,
|
||||
knex: trx,
|
||||
});
|
||||
|
||||
const authorizationService = new AuthorizationService({
|
||||
accountability: this.accountability,
|
||||
knex: trx,
|
||||
|
||||
Reference in New Issue
Block a user