@@ -30,6 +30,7 @@ lazy_static! {
3030
3131#[ derive( Debug , Clone , PartialEq ) ]
3232pub struct AccessControl {
33+ empty : bool ,
3334 use_hashed_password : bool ,
3435 users : IndexMap < String , ( String , AccessPaths ) > ,
3536 anonymous : Option < AccessPaths > ,
@@ -38,6 +39,7 @@ pub struct AccessControl {
3839impl Default for AccessControl {
3940 fn default ( ) -> Self {
4041 AccessControl {
42+ empty : true ,
4143 use_hashed_password : false ,
4244 users : IndexMap :: new ( ) ,
4345 anonymous : Some ( AccessPaths :: new ( AccessPerm :: ReadWrite ) ) ,
@@ -48,7 +50,7 @@ impl Default for AccessControl {
4850impl AccessControl {
4951 pub fn new ( raw_rules : & [ & str ] ) -> Result < Self > {
5052 if raw_rules. is_empty ( ) {
51- return Ok ( Default :: default ( ) ) ;
53+ return Ok ( Self :: default ( ) ) ;
5254 }
5355 let new_raw_rules = split_rules ( raw_rules) ;
5456 let mut use_hashed_password = false ;
@@ -93,13 +95,14 @@ impl AccessControl {
9395 }
9496
9597 Ok ( Self {
98+ empty : false ,
9699 use_hashed_password,
97100 users,
98101 anonymous,
99102 } )
100103 }
101104
102- pub fn exist ( & self ) -> bool {
105+ pub fn has_users ( & self ) -> bool {
103106 !self . users . is_empty ( )
104107 }
105108
@@ -111,7 +114,7 @@ impl AccessControl {
111114 token : Option < & String > ,
112115 guard_options : bool ,
113116 ) -> ( Option < String > , Option < AccessPaths > ) {
114- if self . users . is_empty ( ) {
117+ if self . empty {
115118 return ( None , Some ( AccessPaths :: new ( AccessPerm :: ReadWrite ) ) ) ;
116119 }
117120
0 commit comments