1
0
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:
NG (Graham)
2026-02-14 17:35:09 -05:00
parent b9a6fae1e0
commit 872f224af6
13 changed files with 119 additions and 72 deletions

View File

@@ -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>;
}