implemented some login stuff.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
import Logger from '@ioc:Adonis/Core/Logger'
|
||||
import HttpExceptionHandler from '@ioc:Adonis/Core/HttpExceptionHandler'
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
|
||||
export default class ExceptionHandler extends HttpExceptionHandler {
|
||||
protected statusPages = {
|
||||
@@ -26,4 +27,21 @@ export default class ExceptionHandler extends HttpExceptionHandler {
|
||||
constructor() {
|
||||
super(Logger)
|
||||
}
|
||||
|
||||
public async handle(error: any, ctx: HttpContextContract) {
|
||||
const { session, response } = ctx;
|
||||
|
||||
/**
|
||||
* Handle failed authentication attempt
|
||||
*/
|
||||
if (['E_INVALID_AUTH_PASSWORD', 'E_INVALID_AUTH_UID'].includes(error.code)) {
|
||||
session.flash('errors', { login: error.message });
|
||||
return response.redirect().back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward rest of the exceptions to the parent class
|
||||
*/
|
||||
return super.handle(error, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user