File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,9 @@ pub enum TokenAuthError {
136
136
#[ error( "Password is not valid" ) ]
137
137
InvalidPassword ,
138
138
139
+ #[ error( "User is disabled" ) ]
140
+ UserDisabled ,
141
+
139
142
#[ error( transparent) ]
140
143
Other ( #[ from] anyhow:: Error ) ,
141
144
@@ -160,6 +163,9 @@ pub enum OAuthError {
160
163
#[ error( "The user is not invited to access the system" ) ]
161
164
UserNotInvited ,
162
165
166
+ #[ error( "User is disabled" ) ]
167
+ UserDisabled ,
168
+
163
169
#[ error( transparent) ]
164
170
Other ( #[ from] anyhow:: Error ) ,
165
171
@@ -187,6 +193,9 @@ pub enum RefreshTokenError {
187
193
#[ error( "User not found" ) ]
188
194
UserNotFound ,
189
195
196
+ #[ error( "User is disabled" ) ]
197
+ UserDisabled ,
198
+
190
199
#[ error( transparent) ]
191
200
Other ( #[ from] anyhow:: Error ) ,
192
201
Original file line number Diff line number Diff line change @@ -220,6 +220,10 @@ impl AuthenticationService for DbConn {
220
220
return Err ( TokenAuthError :: UserNotFound ) ;
221
221
} ;
222
222
223
+ if !user. active {
224
+ return Err ( TokenAuthError :: UserDisabled ) ;
225
+ }
226
+
223
227
if !password_verify ( & input. password , & user. password_encrypted ) {
224
228
return Err ( TokenAuthError :: InvalidPassword ) ;
225
229
}
@@ -250,6 +254,10 @@ impl AuthenticationService for DbConn {
250
254
return Err ( RefreshTokenError :: UserNotFound ) ;
251
255
} ;
252
256
257
+ if !user. active {
258
+ return Err ( RefreshTokenError :: UserDisabled ) ;
259
+ }
260
+
253
261
let new_token = generate_refresh_token ( ) ;
254
262
self . replace_refresh_token ( & token, & new_token) . await ?;
255
263
@@ -353,6 +361,9 @@ impl AuthenticationService for DbConn {
353
361
} ;
354
362
355
363
let user = if let Some ( user) = self . get_user_by_email ( & email) . await ? {
364
+ if !user. active {
365
+ return Err ( OAuthError :: UserDisabled ) ;
366
+ }
356
367
user
357
368
} else {
358
369
let Some ( invitation) = self . get_invitation_by_email ( & email) . await ? else {
You can’t perform that action at this time.
0 commit comments