mirror of
https://github.com/arthur-pbty/portfolio2023.git
synced 2026-06-21 13:55:14 +02:00
restart portfolio
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/auth/build/standalone");
|
||||
class AuthMiddleware {
|
||||
constructor() {
|
||||
this.redirectTo = '/login';
|
||||
}
|
||||
async authenticate(auth, guards) {
|
||||
let guardLastAttempted;
|
||||
for (let guard of guards) {
|
||||
guardLastAttempted = guard;
|
||||
if (await auth.use(guard).check()) {
|
||||
auth.defaultGuard = guard;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
throw new standalone_1.AuthenticationException('Unauthorized access', 'E_UNAUTHORIZED_ACCESS', guardLastAttempted, this.redirectTo);
|
||||
}
|
||||
async handle({ auth }, next, customGuards) {
|
||||
const guards = customGuards.length ? customGuards : [auth.name];
|
||||
await this.authenticate(auth, guards);
|
||||
await next();
|
||||
}
|
||||
}
|
||||
exports.default = AuthMiddleware;
|
||||
//# sourceMappingURL=Auth.js.map
|
||||
Reference in New Issue
Block a user