Created
October 21, 2019 20:16
-
-
Save seccomiro/c53bf148b55bab692bddfbbd8bd83d22 to your computer and use it in GitHub Desktop.
Handler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const Config = use('Config'); | |
const BaseExceptionHandler = use('BaseExceptionHandler'); | |
class ExceptionHandler extends BaseExceptionHandler { | |
async handle(error, { response }) { | |
if ( | |
error.name === 'InvalidLoginException' || | |
error.name === 'InvalidSessionException' | |
) { | |
return response.redirect(Config.get('adonis-auth-scaffold.loginRoute')); | |
} | |
if ( | |
error.name === 'HttpException' && | |
error.message.includes('E_GUEST_ONLY') | |
) { | |
return response.redirect( | |
Config.get('adonis-auth-scaffold.registrationSuccessRedirectTo') | |
); | |
} | |
return super.handle(...arguments); | |
} | |
async report(error, { request }) {} | |
} | |
module.exports = ExceptionHandler; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment