1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Add user registration

This commit is contained in:
NG (Graham)
2025-05-12 20:56:24 -04:00
parent d3bd795a01
commit 8affa33ace
14 changed files with 774 additions and 45 deletions

View File

@@ -23,11 +23,24 @@ pub enum ExtraUserInfo {
}
}
pub enum UserId {
SteamId(u64),
Email(String),
Username(String),
}
pub struct UserLoginInfo {
pub response: libfj::robocraft::AuthenticationResponseInfo,
pub is_new: bool,
}
pub struct RegistrationInfo {
pub display_name: String,
pub password: String,
pub email: Option<String>,
pub steam_id: Option<u64>,
}
#[async_trait::async_trait]
pub trait UserProvider<C> {
async fn authenticate(&self, user: UserToken, ext: std::collections::HashMap<std::any::TypeId, Box<dyn std::any::Any + Send + Sync + 'static>>) -> Result<Box<dyn User<C> + Send + Sync>, String>;
@@ -36,6 +49,8 @@ pub trait UserProvider<C> {
#[async_trait::async_trait]
pub trait UserAuthenticator {
async fn login(&self, info: UserInfo) -> Result<UserLoginInfo, String>;
async fn user_exists(&self, user: UserId) -> Result<bool, String>;
async fn register(&self, info: RegistrationInfo) -> Result<u32, String>;
}
#[async_trait::async_trait]