You've already forked AstralRinth
forked from didirus/AstralRinth
Authenticate protected routes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use super::ids::Base62Id;
|
||||
use super::teams::TeamId;
|
||||
use super::users::UserId;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -54,6 +55,8 @@ pub struct Version {
|
||||
pub id: VersionId,
|
||||
/// The ID of the mod this version is for.
|
||||
pub mod_id: ModId,
|
||||
/// The ID of the author who published this version
|
||||
pub author_id: UserId,
|
||||
|
||||
/// The name of this version
|
||||
pub name: String,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::ids::Base62Id;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::models::users::UserId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
//TODO Implement Item for teams
|
||||
/// The ID of a team
|
||||
|
||||
@@ -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