@@ -14,30 +14,34 @@ export default async function login(req: ReqType, res: ResType) {
1414 let password = req . body . password ;
1515 let captchaSolution = req . body . captchaSolution ;
1616
17- // Verify CAPTCHA solution
18- const isCaptchaValid = powCaptcha . check ( captchaSolution , `login:${ req . ip } ` ) ;
19- if ( ! isCaptchaValid ) {
20- return inertiaAdminMessage ( req , "Invalid CAPTCHA solution" , 'captchaSolution' ) ;
21- }
22-
2317 let user : ModelsAP [ "UserAP" ] ;
2418 try {
2519 // TODO refactor CRUD functions for DataAccessor usage
2620 user = await req . adminizer . modelHandler . model . get ( "UserAP" ) [ "_findOne" ] ( { login : login } ) ;
2721 } catch ( e ) {
2822 return res . status ( 500 ) . send ( { error : e . message || 'Internal Server Error' } ) ;
2923 }
24+
3025 if ( req . body . pretend ) {
3126 if ( ! user ) {
3227 return res . sendStatus ( 404 ) ;
3328 }
3429 if ( req . session . UserAP . isAdministrator ) {
3530 req . session . adminPretender = req . session . UserAP ;
3631 req . session . UserAP = user ;
37- return res . sendStatus ( 200 ) ;
32+ // return res.sendStatus(200);
33+ return req . Inertia . redirect ( `${ req . adminizer . config . routePrefix } ` ) ;
3834 }
35+ return req . Inertia . redirect ( `${ req . adminizer . config . routePrefix } /` ) ;
3936 }
4037
38+ // Verify CAPTCHA solution
39+ const isCaptchaValid = powCaptcha . check ( captchaSolution , `login:${ req . ip } ` ) ;
40+ if ( ! isCaptchaValid ) {
41+ return inertiaAdminMessage ( req , "Invalid CAPTCHA solution" , 'captchaSolution' ) ;
42+ }
43+
44+
4145 if ( ! user ) {
4246 return inertiaAdminMessage ( req , "Wrong username" , 'login' ) ;
4347 } else {
0 commit comments