Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Fix creator payouts + scheduler #686

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 1 addition & 62 deletions src/auth/flows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ pub fn config(cfg: &mut ServiceConfig) {
.service(resend_verify_email)
.service(set_email)
.service(verify_email)
.service(subscribe_newsletter)
.service(login_from_minecraft)
.configure(super::minecraft::config),
.service(subscribe_newsletter),
);
}

Expand Down Expand Up @@ -1177,65 +1175,6 @@ pub async fn auth_callback(
Ok(res?)
}

#[derive(Deserialize)]
pub struct MinecraftLogin {
pub flow: String,
}

#[post("login/minecraft")]
pub async fn login_from_minecraft(
req: HttpRequest,
client: Data<PgPool>,
file_host: Data<Arc<dyn FileHost + Send + Sync>>,
redis: Data<deadpool_redis::Pool>,
login: web::Json<MinecraftLogin>,
) -> Result<HttpResponse, AuthenticationError> {
let flow = Flow::get(&login.flow, &redis).await?;

// Extract cookie header from request
if let Some(Flow::MicrosoftLogin {
access_token: token,
}) = flow
{
Flow::remove(&login.flow, &redis).await?;
let provider = AuthProvider::Microsoft;
let oauth_user = provider.get_user(&token).await?;
let user_id_opt = provider.get_user_id(&oauth_user.id, &**client).await?;

let mut transaction = client.begin().await?;

let user_id = if let Some(user_id) = user_id_opt {
let user = crate::database::models::User::get_id(user_id, &**client, &redis)
.await?
.ok_or_else(|| AuthenticationError::InvalidCredentials)?;

if user.totp_secret.is_some() {
let flow = Flow::Login2FA { user_id: user.id }
.insert(Duration::minutes(30), &redis)
.await?;

return Ok(HttpResponse::Ok().json(serde_json::json!({
"error": "2fa_required",
"flow": flow
})));
}

user_id
} else {
oauth_user
.create_account(provider, &mut transaction, &client, &file_host, &redis)
.await?
};

let session = issue_session(req, user_id, &mut transaction, &redis).await?;
Ok(HttpResponse::Ok().json(serde_json::json!({
"code": session.session
})))
} else {
Err(AuthenticationError::InvalidCredentials)
}
}

#[derive(Deserialize)]
pub struct DeleteAuthProvider {
pub provider: AuthProvider,
Expand Down
160 changes: 0 additions & 160 deletions src/auth/minecraft/auth.rs

This file was deleted.

35 changes: 0 additions & 35 deletions src/auth/minecraft/login.rs

This file was deleted.

60 changes: 0 additions & 60 deletions src/auth/minecraft/mod.rs

This file was deleted.

Loading
Loading