File tree Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,20 @@ impl User {
3030 pub fn is_valid ( & self ) -> bool {
3131 self . locked_at . is_none ( ) && self . deactivated_at . is_none ( )
3232 }
33+
34+ /// Returns `true` if the user is a valid actor, for example
35+ /// of a personal session.
36+ ///
37+ /// Currently: this is `true` unless the user is deactivated.
38+ ///
39+ /// This is a weaker form of validity: `is_valid` always implies
40+ /// `is_valid_actor`, but some users (currently: locked users)
41+ /// can be valid actors for personal sessions but aren't valid
42+ /// except through administrative access.
43+ #[ must_use]
44+ pub fn is_valid_actor ( & self ) -> bool {
45+ self . deactivated_at . is_none ( )
46+ }
3347}
3448
3549impl User {
Original file line number Diff line number Diff line change @@ -264,11 +264,20 @@ where
264264 None
265265 } ;
266266
267- // If there is a user for this session, check that it is not locked
268- if let Some ( user) = & user
269- && !user. is_valid ( )
270- {
271- return Err ( Rejection :: UserLocked ) ;
267+ if let CallerSession :: PersonalSession ( _) = & session {
268+ // For personal sessions: check that the actor is valid enough
269+ // to be an actor.
270+ // unwrap: personal sessions always have an actor user
271+ if !user. as_ref ( ) . unwrap ( ) . is_valid_actor ( ) {
272+ return Err ( Rejection :: UserLocked ) ;
273+ }
274+ } else {
275+ // If there is a user for this session, check that it is not locked
276+ if let Some ( user) = & user
277+ && !user. is_valid ( )
278+ {
279+ return Err ( Rejection :: UserLocked ) ;
280+ }
272281 }
273282
274283 // For now, we only check that the session has the admin scope
You can’t perform that action at this time.
0 commit comments