You've already forked AstralRinth
forked from didirus/AstralRinth
Authenticate protected routes
This commit is contained in:
@@ -16,4 +16,32 @@ pub struct User {
|
||||
pub avatar_url: String,
|
||||
pub bio: String,
|
||||
pub created: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
pub role: Role,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum Role {
|
||||
Developer,
|
||||
Moderator,
|
||||
Admin,
|
||||
}
|
||||
|
||||
impl ToString for Role {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
Role::Developer => String::from("developer"),
|
||||
Role::Moderator => String::from("moderator"),
|
||||
Role::Admin => String::from("admin"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Role {
|
||||
pub fn from_string(string: &str) -> Role {
|
||||
match string {
|
||||
"admin" => Role::Admin,
|
||||
"moderator" => Role::Moderator,
|
||||
_ => Role::Developer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user