@@ -68,6 +68,7 @@ pub async fn login(
6868 name : param. username . clone ( ) ,
6969 password : password. clone ( ) ,
7070 } ;
71+ let mut error_code = "USER_CHECK_ERROR" . to_owned ( ) ;
7172 if let Ok ( Ok ( res) ) = app. user_manager . send ( msg) . await {
7273 if let UserManagerResult :: CheckUserResult ( valid, user) = res {
7374 if valid {
@@ -82,20 +83,19 @@ pub async fn login(
8283 }
8384 }
8485 if !app. sys_config . ldap_enable && session. is_none ( ) {
85- return HttpResponse :: Ok ( )
86- . json ( ApiResult :: < ( ) > :: error ( "USER_CHECK_ERROR" . to_owned ( ) , None ) ) ;
86+ return HttpResponse :: Ok ( ) . json ( ApiResult :: < ( ) > :: error ( error_code, None ) ) ;
8787 }
88+ } else {
89+ error_code = "SYSTEM_ERROR" . to_owned ( ) ;
8890 }
8991 if session. is_none ( ) && app. sys_config . ldap_enable {
9092 match ldap_login ( & app, param. clone ( ) , password) . await {
9193 Ok ( v) => {
9294 session = v;
9395 }
9496 Err ( e) => {
95- return HttpResponse :: Ok ( ) . json ( ApiResult :: < ( ) > :: error (
96- "SYSTEM_ERROR" . to_owned ( ) ,
97- Some ( e. to_string ( ) ) ,
98- ) ) ;
97+ return HttpResponse :: Ok ( )
98+ . json ( ApiResult :: < ( ) > :: error ( error_code, Some ( e. to_string ( ) ) ) ) ;
9999 }
100100 }
101101 }
@@ -104,7 +104,7 @@ pub async fn login(
104104 return value;
105105 }
106106 }
107- HttpResponse :: Ok ( ) . json ( ApiResult :: < ( ) > :: error ( "SYSTEM_ERROR" . to_owned ( ) , None ) )
107+ HttpResponse :: Ok ( ) . json ( ApiResult :: < ( ) > :: error ( error_code , None ) )
108108}
109109
110110fn apply_session (
0 commit comments