File tree Expand file tree Collapse file tree 2 files changed +17
-29
lines changed
Expand file tree Collapse file tree 2 files changed +17
-29
lines changed Original file line number Diff line number Diff line change 11<template >
2-
2+ < div class = " w-full flex justify-center items-center " >
33 <div :id =" props.meta.containerId" ></div >
4-
4+ </ div >
55</template >
66
77<script setup lang="ts">
@@ -22,16 +22,16 @@ const props = defineProps<Props>();
2222
2323const token = ref (null );
2424const emit = defineEmits (
25- [" update:allowLoginClick " ]
25+ [" update:disableLoginButton " ]
2626)
2727
2828onMounted (() => {
2929 const fnName = props .meta .renderWidgetFunctionName ;
30-
30+ emit ( " update:disableLoginButton " , true );
3131 const renderFn = (window as any )[fnName ];
3232 if (typeof renderFn === ' function' ) {
3333 renderFn (props .meta .containerId , props .meta .siteKey , (receivedToken : string ) => {
34- emit (" update:allowLoginClick " , true );
34+ emit (" update:disableLoginButton " , false );
3535 token .value = receivedToken ;
3636 setJWT (receivedToken );
3737 });
Original file line number Diff line number Diff line change @@ -47,43 +47,31 @@ export default class CaptchaPlugin extends AdminForthPlugin {
4747
4848 const beforeLoginConfirmation = this . adminforth . config . auth . beforeLoginConfirmation ;
4949 const beforeLoginConfirmationArray = Array . isArray ( beforeLoginConfirmation ) ? beforeLoginConfirmation : [ beforeLoginConfirmation ] ;
50- beforeLoginConfirmationArray . push (
50+ beforeLoginConfirmationArray . unshift (
5151 async ( { extra } : { adminUser : AdminUser , response : IAdminForthHttpResponse , extra ?: any } ) => {
52+ const rejectResult = {
53+ body :{
54+ allowedLogin : false ,
55+ redirectTo : '/login' ,
56+ } ,
57+ ok : true
58+ } ;
59+
5260 if ( ! extra || ! extra . cookies ) {
53- return {
54- body :{
55- allowedLogin : false ,
56- redirectTo : '/login' ,
57- } ,
58- ok : true
59- }
61+ return rejectResult ;
6062 }
6163 const cookies = extra . cookies ;
6264 const token = cookies . find (
6365 ( cookie ) => cookie . key === `adminforth_${ adapterName } _temporaryJWT`
6466 ) ?. value ;
6567 if ( ! token ) {
66- return {
67- body :{
68- allowedLogin : false ,
69- redirectTo : '/login' ,
70- } ,
71- ok : true
72- }
68+ return rejectResult ;
7369 }
7470
7571 const ip = this . adminforth . auth . getClientIp ( extra . headers ) ;
7672 const validationResult = await this . options . captchaAdapter . validate ( token , ip ) ;
77- console . log ( 'Validation result:' , validationResult ) ;
78-
7973 if ( ! validationResult || ! validationResult . success ) {
80- return {
81- body :{
82- allowedLogin : false ,
83- redirectTo : '/login' ,
84- } ,
85- ok : true
86- }
74+ return rejectResult ;
8775 }
8876 }
8977 ) ;
You can’t perform that action at this time.
0 commit comments