1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-20 12:02:22 +03:00

Fix the upstream oauth registration form

This commit is contained in:
Quentin Gliech
2023-06-30 11:24:26 +02:00
parent dc629d195e
commit e1a5471262
3 changed files with 17 additions and 5 deletions

View File

@@ -75,6 +75,9 @@ pub(crate) enum RouteError {
#[error("Invalid form action")]
InvalidFormAction,
#[error("Missing username")]
MissingUsername,
#[error(transparent)]
Internal(Box<dyn std::error::Error>),
}
@@ -147,7 +150,8 @@ fn import_claim(
#[serde(rename_all = "lowercase", tag = "action")]
pub(crate) enum FormData {
Register {
username: String,
#[serde(default)]
username: Option<String>,
#[serde(default)]
import_email: Option<String>,
#[serde(default)]
@@ -456,11 +460,13 @@ pub(crate) async fn post(
|value, force| {
// If the username is forced, override whatever was in the form
if force {
username = value;
username = Some(value);
}
},
)?;
let username = username.ok_or(RouteError::MissingUsername)?;
// Now we can create the user
let user = repo.user().add(&mut rng, &clock, username).await?;