@@ -68,6 +68,7 @@ pub async fn login(
68
68
name : param. username . clone ( ) ,
69
69
password : password. clone ( ) ,
70
70
} ;
71
+ let mut error_code = "USER_CHECK_ERROR" . to_owned ( ) ;
71
72
if let Ok ( Ok ( res) ) = app. user_manager . send ( msg) . await {
72
73
if let UserManagerResult :: CheckUserResult ( valid, user) = res {
73
74
if valid {
@@ -82,20 +83,19 @@ pub async fn login(
82
83
}
83
84
}
84
85
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 ) ) ;
87
87
}
88
+ } else {
89
+ error_code = "SYSTEM_ERROR" . to_owned ( ) ;
88
90
}
89
91
if session. is_none ( ) && app. sys_config . ldap_enable {
90
92
match ldap_login ( & app, param. clone ( ) , password) . await {
91
93
Ok ( v) => {
92
94
session = v;
93
95
}
94
96
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 ( ) ) ) ) ;
99
99
}
100
100
}
101
101
}
@@ -104,7 +104,7 @@ pub async fn login(
104
104
return value;
105
105
}
106
106
}
107
- HttpResponse :: Ok ( ) . json ( ApiResult :: < ( ) > :: error ( "SYSTEM_ERROR" . to_owned ( ) , None ) )
107
+ HttpResponse :: Ok ( ) . json ( ApiResult :: < ( ) > :: error ( error_code , None ) )
108
108
}
109
109
110
110
fn apply_session (
0 commit comments