- update to AdonisJS 6

This commit is contained in:
Kaimbacher 2024-03-14 20:25:27 +01:00
parent f828ca4491
commit cb51a4136f
167 changed files with 21485 additions and 21212 deletions

View file

@ -1,11 +1,12 @@
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
import Config from '@ioc:Adonis/Core/Config';
import Database from '@ioc:Adonis/Lucid/Database';
import User from 'App/Models/User';
import { HttpContext } from '@adonisjs/core/http';
// import Config from '@ioc:Adonis/Core/Config';
import config from '@adonisjs/core/services/config'
import db from '@adonisjs/lucid/services/db';
import User from '#app/Models/User';
// import { Exception } from '@adonisjs/core/build/standalone'
const roleTable = Config.get('rolePermission.role_table', 'roles');
const userRoleTable = Config.get('rolePermission.user_role_table', 'user_roles');
const roleTable = config.get('rolePermission.role_table', 'roles');
const userRoleTable = config.get('rolePermission.user_role_table', 'user_roles');
/**
* Role authentication to check if user has any of the specified roles
@ -16,7 +17,7 @@ export default class Is {
/**
* Handle request
*/
public async handle({ auth, response }: HttpContextContract, next: () => Promise<void>, roleNames: string[]) {
public async handle({ auth, response }: HttpContext, next: () => Promise<void>, roleNames: string[]) {
/**
* Check if user is logged-in or not.
*/
@ -33,7 +34,8 @@ export default class Is {
// 401,
// "E_INVALID_AUTH_UID");
}
await next();
// await next();
return next()
}
private async checkHasRoles(user: User, roleNames: Array<string>): Promise<boolean> {
@ -46,7 +48,7 @@ export default class Is {
0: {
0: { roleCount },
},
} = await Database.rawQuery(
} = await db.rawQuery(
'SELECT count(`ur`.`id`) as roleCount FROM ' +
userRoleTable +
' ur INNER JOIN ' +