mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Simplify login data struct, add experimental login flags
This commit is contained in:
@@ -6,23 +6,35 @@ pub struct UserToken {
|
||||
pub refresh_token: String,
|
||||
}
|
||||
|
||||
pub struct UserInfo {
|
||||
pub payload: libfj::robocraft::TokenPayload,
|
||||
/*pub struct UserInfo {
|
||||
//pub payload: libfj::robocraft::TokenPayload,
|
||||
pub extra: ExtraUserInfo,
|
||||
}
|
||||
}*/
|
||||
|
||||
pub enum ExtraUserInfo {
|
||||
pub enum UserAuthInfo {
|
||||
Steam {
|
||||
id: u64,
|
||||
},
|
||||
Username {
|
||||
username: String,
|
||||
password: String,
|
||||
},
|
||||
Email {
|
||||
email: String,
|
||||
password: String,
|
||||
}
|
||||
}
|
||||
|
||||
impl UserAuthInfo {
|
||||
pub(super) fn display_id(&self) -> String {
|
||||
match self {
|
||||
Self::Steam { id } => format!("steamID:{}", id),
|
||||
Self::Username { username, .. } => format!("username:{}", username),
|
||||
Self::Email { email, .. } => format!("email:{}", email),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum UserId {
|
||||
SteamId(u64),
|
||||
Email(String),
|
||||
@@ -55,7 +67,7 @@ pub trait UserProvider<C> {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait UserAuthenticator {
|
||||
async fn login(&self, info: UserInfo) -> Result<UserLoginInfo, AuthError>;
|
||||
async fn login(&self, info: UserAuthInfo) -> Result<UserLoginInfo, AuthError>;
|
||||
async fn user_exists(&self, user: UserId) -> Result<bool, String>;
|
||||
async fn register(&self, info: RegistrationInfo) -> Result<i32, String>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user