mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Prefix all crates with oj_ and use release version of dependencies
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "auth"
|
||||
name = "oj_auth"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -9,7 +9,7 @@ authors.workspace = true
|
||||
|
||||
[features]
|
||||
steam = ["steamworks"]
|
||||
robocraft = ["rc_core"]
|
||||
robocraft = ["oj_rc_core"]
|
||||
cardlife = []
|
||||
default = ["robocraft", "cardlife"]
|
||||
|
||||
@@ -24,6 +24,6 @@ steamworks = { version = "0.11", optional = true }
|
||||
hex = "0.4"
|
||||
jsonwebtoken = "9"
|
||||
clap.workspace = true
|
||||
rc_core = { version = "*", optional = true, path = "../rc_core" }
|
||||
oj_rc_core = { version = "*", optional = true, path = "../rc_core" }
|
||||
serde.workspace = true
|
||||
git-version.workspace = true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rc_core::UserAuthenticator;
|
||||
use oj_rc_core::UserAuthenticator;
|
||||
use rocket::{post, routes, serde::json::Json, http::Status, State};
|
||||
|
||||
#[post("/authenticate/email/game", data = "<body>")]
|
||||
@@ -12,9 +12,9 @@ pub async fn email_password_auth(body: Json<libfj::robocraft::EmailUserAuthentic
|
||||
email_verified: true,
|
||||
flags: Vec::new(),
|
||||
};
|
||||
let user_info = rc_core::persist::user::UserInfo {
|
||||
let user_info = oj_rc_core::persist::user::UserInfo {
|
||||
payload,
|
||||
extra: rc_core::persist::user::ExtraUserInfo::Email { password: body.password.clone() },
|
||||
extra: oj_rc_core::persist::user::ExtraUserInfo::Email { password: body.password.clone() },
|
||||
};
|
||||
let response = config.robocraft.account_provider.login(user_info).await
|
||||
.map_err(|e| {
|
||||
|
||||
@@ -18,15 +18,15 @@ pub fn stage() -> rocket::fairing::AdHoc {
|
||||
#[allow(dead_code)]
|
||||
pub struct RcConfig {
|
||||
pub data: std::path::PathBuf,
|
||||
pub account_provider: rc_core::UserImpl,
|
||||
pub account_provider: oj_rc_core::UserImpl,
|
||||
pub assets: std::path::PathBuf,
|
||||
}
|
||||
|
||||
impl RcConfig {
|
||||
pub async fn from_args(args: &crate::common::cli::CliArgs) -> Self {
|
||||
let conf = rc_core::persist::config::ConfigImpl::load(&args.assets_robocraft).expect("Bad config data");
|
||||
let conf = oj_rc_core::persist::config::ConfigImpl::load(&args.assets_robocraft).expect("Bad config data");
|
||||
Self {
|
||||
account_provider: rc_core::UserImpl::load(&args.data_robocraft, &conf).await.expect("Invalid Robocraft user data"),
|
||||
account_provider: oj_rc_core::UserImpl::load(&args.data_robocraft, &conf).await.expect("Invalid Robocraft user data"),
|
||||
data: args.data_robocraft.clone().into(),
|
||||
assets: args.assets_robocraft.clone().into(),
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rc_core::UserAuthenticator;
|
||||
use oj_rc_core::UserAuthenticator;
|
||||
use rocket::{post, get, form::{Form, FromForm}, routes, http::Status, State};
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use serde::Serialize;
|
||||
@@ -86,7 +86,7 @@ async fn form_submit(form: Form<RegisterForm>, config: &State<crate::common::cli
|
||||
if !email.contains('@') {
|
||||
return Ok(registration_err(form.into_inner(), "Email must contain @".to_owned()));
|
||||
}
|
||||
let email_exists = config.robocraft.account_provider.user_exists(rc_core::persist::user::UserId::Email(email.to_owned()))
|
||||
let email_exists = config.robocraft.account_provider.user_exists(oj_rc_core::persist::user::UserId::Email(email.to_owned()))
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to check if user email {} exists: {}", email, e);
|
||||
@@ -114,7 +114,7 @@ async fn form_submit(form: Form<RegisterForm>, config: &State<crate::common::cli
|
||||
if steam_id >= 7656120_0000000000 || steam_id < 7656119_0000000000 {
|
||||
return Ok(registration_err(form.into_inner(), "Invalid SteamID (should be like 7656119XXXXXXXXXX)".to_owned()));
|
||||
}
|
||||
let steam_exists = config.robocraft.account_provider.user_exists(rc_core::persist::user::UserId::SteamId(steam_id))
|
||||
let steam_exists = config.robocraft.account_provider.user_exists(oj_rc_core::persist::user::UserId::SteamId(steam_id))
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to check if user steam id {} exists: {}", steam_id, e);
|
||||
@@ -139,7 +139,7 @@ async fn form_submit(form: Form<RegisterForm>, config: &State<crate::common::cli
|
||||
if !all_valid_chars(&form.display_name.to_lowercase()) {
|
||||
return Ok(registration_err(form.into_inner(), "Invalid username (only alphanumerics and _ allowed)".to_owned()));
|
||||
}
|
||||
let username_exists = config.robocraft.account_provider.user_exists(rc_core::persist::user::UserId::Username(form.display_name.to_owned()))
|
||||
let username_exists = config.robocraft.account_provider.user_exists(oj_rc_core::persist::user::UserId::Username(form.display_name.to_owned()))
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to check if user name {} exists: {}", form.display_name, e);
|
||||
@@ -149,7 +149,7 @@ async fn form_submit(form: Form<RegisterForm>, config: &State<crate::common::cli
|
||||
return Ok(registration_err(form.into_inner(), "Username already registered".to_owned()));
|
||||
}
|
||||
|
||||
let user_id = match config.robocraft.account_provider.register(rc_core::persist::user::RegistrationInfo {
|
||||
let user_id = match config.robocraft.account_provider.register(oj_rc_core::persist::user::RegistrationInfo {
|
||||
display_name: form.display_name.clone(),
|
||||
password: form.password.clone(),
|
||||
email: actual_email,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rc_core::UserAuthenticator;
|
||||
use oj_rc_core::UserAuthenticator;
|
||||
use rocket::{http::Status, post, routes, serde::json::Json, State};
|
||||
|
||||
#[post("/authenticate/steam/game", data = "<body>")]
|
||||
@@ -14,9 +14,9 @@ pub async fn steam_auth(body: Json<libfj::robocraft::SteamAuthenticationPayload>
|
||||
email_verified: true,
|
||||
flags: Vec::new(),
|
||||
};
|
||||
let user_info = rc_core::persist::user::UserInfo {
|
||||
let user_info = oj_rc_core::persist::user::UserInfo {
|
||||
payload,
|
||||
extra: rc_core::persist::user::ExtraUserInfo::Steam { id: steam_id },
|
||||
extra: oj_rc_core::persist::user::ExtraUserInfo::Steam { id: steam_id },
|
||||
};
|
||||
let response = config.robocraft.account_provider.login(user_info).await
|
||||
.map_err(|e| {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rc_core::UserAuthenticator;
|
||||
use oj_rc_core::UserAuthenticator;
|
||||
use rocket::{post, routes, serde::json::Json, http::Status, State};
|
||||
|
||||
#[post("/authenticate/robocraft/game", data = "<body>")]
|
||||
@@ -12,9 +12,9 @@ pub async fn user_password_auth(body: Json<libfj::robocraft::EmailUserAuthentica
|
||||
email_verified: true,
|
||||
flags: Vec::new(),
|
||||
};
|
||||
let user_info = rc_core::persist::user::UserInfo {
|
||||
let user_info = oj_rc_core::persist::user::UserInfo {
|
||||
payload,
|
||||
extra: rc_core::persist::user::ExtraUserInfo::Username { password: body.password.clone() },
|
||||
extra: oj_rc_core::persist::user::ExtraUserInfo::Username { password: body.password.clone() },
|
||||
};
|
||||
let response = config.robocraft.account_provider.login(user_info).await
|
||||
.map_err(|e| {
|
||||
|
||||
Reference in New Issue
Block a user