Skip to content

Commit 463c533

Browse files
committed
refactor: [#615] new panic messages and minor refactorings
1 parent 7104b61 commit 463c533

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/services/authorization.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,18 @@ impl CasbinEnforcer {
8888
pub async fn new() -> Self {
8989
let casbin_configuration = CasbinConfiguration::new();
9090

91-
let model = DefaultModel::from_str(&casbin_configuration.model).await.unwrap();
91+
let model = DefaultModel::from_str(&casbin_configuration.model)
92+
.await
93+
.expect("Error loading the model");
9294

9395
let policy = casbin_configuration.policy;
9496

95-
let mut enforcer = Enforcer::new(model, ()).await.unwrap();
97+
let mut enforcer = Enforcer::new(model, ()).await.expect("Error creating the enforcer");
9698

97-
enforcer.add_policies(policy).await.unwrap();
99+
enforcer.add_policies(policy).await.expect("Error loading the policy");
98100

99101
let enforcer = Arc::new(RwLock::new(enforcer));
100-
//casbin_enforcer.enable_log(true);
102+
101103
Self { enforcer }
102104
}
103105
}
@@ -126,14 +128,14 @@ impl CasbinConfiguration {
126128
",
127129
),
128130
policy: vec![
129-
vec!["admin".to_owned(), "AddCategory".to_owned()],
130-
vec!["admin".to_owned(), "DeleteCategory".to_owned()],
131-
vec!["admin".to_owned(), "GetSettings".to_owned()],
132-
vec!["admin".to_owned(), "GetSettingsSecret".to_owned()],
133-
vec!["admin".to_owned(), "AddTag".to_owned()],
134-
vec!["admin".to_owned(), "DeleteTag".to_owned()],
135-
vec!["admin".to_owned(), "DeleteTorrent".to_owned()],
136-
vec!["admin".to_owned(), "BanUser".to_owned()],
131+
vec!["admin".to_string(), "AddCategory".to_string()],
132+
vec!["admin".to_string(), "DeleteCategory".to_string()],
133+
vec!["admin".to_string(), "GetSettings".to_string()],
134+
vec!["admin".to_string(), "GetSettingsSecret".to_string()],
135+
vec!["admin".to_string(), "AddTag".to_string()],
136+
vec!["admin".to_string(), "DeleteTag".to_string()],
137+
vec!["admin".to_string(), "DeleteTorrent".to_string()],
138+
vec!["admin".to_string(), "BanUser".to_string()],
137139
],
138140
}
139141
}

0 commit comments

Comments
 (0)