Skip to content

Commit 774b41e

Browse files
committed
refactor: use ends_with in role parser
1 parent 8a6b819 commit 774b41e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

vicky/src/bin/vicky/auth.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ impl FromStr for Role {
2626
type Err = ();
2727

2828
fn from_str(s: &str) -> Result<Self, Self::Err> {
29-
match s {
30-
"vicky:admin" => Ok(Self::Admin),
31-
"vicky:machine" => Ok(Self::Machine),
32-
_ => Err(()),
29+
if s.ends_with("admin") {
30+
Ok(Self::Admin)
31+
} else if s.ends_with("machine") {
32+
Ok(Self::Machine)
33+
} else {
34+
Err(())
3335
}
3436
}
3537
}

0 commit comments

Comments
 (0)