Simplify login data struct, add experimental login flags

This commit is contained in:
NG (Graham) committed 2026-02-14 18:08:12 -05:00
1 parent b9a6fae1e0
commit 872f224af6
13 files changed
+119 -72

No files matched your search

+17 -5
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>;
}