@@ -2,7 +2,7 @@ use std::collections::HashMap;
22use std:: sync:: Arc ;
33
44use super :: model:: login_model:: { LoginConfig , LoginParam , LoginToken } ;
5- use crate :: cache:: actor_model:: CacheSetParam ;
5+ use crate :: cache:: actor_model:: { CacheManagerRaftResult , CacheSetParam } ;
66use crate :: ldap:: model:: actor_model:: { LdapMsgReq , LdapMsgResult } ;
77use crate :: ldap:: model:: LdapUserParam ;
88use crate :: oauth2:: model:: actor_model:: { OAuth2MsgReq , OAuth2MsgResult } ;
@@ -344,17 +344,18 @@ async fn check_captcha(
344344 Some ( "captcha token is empty" . to_owned ( ) ) ,
345345 ) ) ) ;
346346 }
347- let cache_req = CacheManagerReq :: Get ( CacheKey :: new (
347+ let req = crate :: cache :: actor_model :: CacheManagerLocalReq :: Get ( CacheKey :: new (
348348 CacheType :: String ,
349349 Arc :: new ( format ! ( "Captcha_{}" , & captcha_token) ) ,
350350 ) ) ;
351- let captcha_check_result = if let Ok ( Ok ( CacheManagerResult :: Value ( CacheValue :: String ( v) ) ) ) =
352- app. cache_manager . send ( cache_req) . await
353- {
354- & captcha_code == v. as_ref ( )
355- } else {
356- false
357- } ;
351+ let captcha_check_result =
352+ if let Ok ( Ok ( CacheManagerRaftResult :: Value ( crate :: cache:: model:: CacheValue :: String ( v) ) ) ) =
353+ app. direct_cache_manager . send ( req) . await
354+ {
355+ & captcha_code == v. as_ref ( )
356+ } else {
357+ false
358+ } ;
358359 if !captcha_check_result {
359360 return Some (
360361 HttpResponse :: Ok ( )
@@ -419,12 +420,16 @@ pub async fn gen_captcha(app: Data<Arc<AppShareData>>) -> actix_web::Result<impl
419420
420421 let img = obj. as_base64 ( ) . unwrap_or_default ( ) ;
421422 //log::info!("gen_captcha code:{}", &code);
422- let cache_req = CacheManagerReq :: Set {
423- key : CacheKey :: new ( CacheType :: String , Arc :: new ( format ! ( "Captcha_{}" , & token) ) ) ,
424- value : CacheValue :: String ( code) ,
425- ttl : 300 ,
426- } ;
427- app. cache_manager . send ( cache_req) . await . ok ( ) ;
423+ let cache_req =
424+ crate :: cache:: actor_model:: CacheManagerRaftReq :: Set ( CacheSetParam :: new_with_ttl (
425+ CacheKey :: new ( CacheType :: String , Arc :: new ( format ! ( "Captcha_{}" , & token) ) ) ,
426+ crate :: cache:: model:: CacheValue :: String ( code) ,
427+ 300 ,
428+ ) ) ;
429+ app. raft_request_route
430+ . request ( ClientRequest :: CacheReq { req : cache_req } )
431+ . await
432+ . ok ( ) ;
428433 Ok ( HttpResponse :: Ok ( )
429434 . cookie ( captcha_cookie)
430435 . insert_header ( captcha_header)
0 commit comments