You've already forked authentication-service
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:
@@ -75,6 +75,9 @@ pub(crate) enum RouteError {
|
|||||||
#[error("Invalid form action")]
|
#[error("Invalid form action")]
|
||||||
InvalidFormAction,
|
InvalidFormAction,
|
||||||
|
|
||||||
|
#[error("Missing username")]
|
||||||
|
MissingUsername,
|
||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Internal(Box<dyn std::error::Error>),
|
Internal(Box<dyn std::error::Error>),
|
||||||
}
|
}
|
||||||
@@ -147,7 +150,8 @@ fn import_claim(
|
|||||||
#[serde(rename_all = "lowercase", tag = "action")]
|
#[serde(rename_all = "lowercase", tag = "action")]
|
||||||
pub(crate) enum FormData {
|
pub(crate) enum FormData {
|
||||||
Register {
|
Register {
|
||||||
username: String,
|
#[serde(default)]
|
||||||
|
username: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
import_email: Option<String>,
|
import_email: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -456,11 +460,13 @@ pub(crate) async fn post(
|
|||||||
|value, force| {
|
|value, force| {
|
||||||
// If the username is forced, override whatever was in the form
|
// If the username is forced, override whatever was in the form
|
||||||
if force {
|
if force {
|
||||||
username = value;
|
username = Some(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
let username = username.ok_or(RouteError::MissingUsername)?;
|
||||||
|
|
||||||
// Now we can create the user
|
// Now we can create the user
|
||||||
let user = repo.user().add(&mut rng, &clock, username).await?;
|
let user = repo.user().add(&mut rng, &clock, username).await?;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
#}
|
#}
|
||||||
|
|
||||||
{% macro input(label, name, type="text", form_state=false, autocomplete=false, class="", inputmode="text", autocorrect=false, autocapitalize=false, disabled=false, value="") %}
|
{% macro input(label, name, type="text", form_state=false, autocomplete=false, class="", inputmode="text", autocorrect=false, autocapitalize=false, disabled=false) %}
|
||||||
{% if not form_state %}
|
{% if not form_state %}
|
||||||
{% set form_state = dict(errors=[], fields=dict()) %}
|
{% set form_state = dict(errors=[], fields=dict()) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -35,7 +35,6 @@ limitations under the License.
|
|||||||
class="z-0 px-3 py-2 bg-white dark:bg-black-900 rounded-lg {{ border_color }} border-2 focus:border-accent focus:ring-0 focus:outline-0"
|
class="z-0 px-3 py-2 bg-white dark:bg-black-900 rounded-lg {{ border_color }} border-2 focus:border-accent focus:ring-0 focus:outline-0"
|
||||||
type="{{ type }}"
|
type="{{ type }}"
|
||||||
inputmode="{{ inputmode }}"
|
inputmode="{{ inputmode }}"
|
||||||
value="{{ state.value | default(value=value) }}"
|
|
||||||
{% if disabled %} disabled {% endif %}
|
{% if disabled %} disabled {% endif %}
|
||||||
{% if autocomplete %} autocomplete="{{ autocomplete }}" {% endif %}
|
{% if autocomplete %} autocomplete="{{ autocomplete }}" {% endif %}
|
||||||
{% if autocorrect %} autocorrect="{{ autocorrect }}" {% endif %}
|
{% if autocorrect %} autocorrect="{{ autocorrect }}" {% endif %}
|
||||||
|
|||||||
@@ -30,7 +30,14 @@ limitations under the License.
|
|||||||
|
|
||||||
<input type="hidden" name="csrf" value="{{ csrf_token }}" />
|
<input type="hidden" name="csrf" value="{{ csrf_token }}" />
|
||||||
<input type="hidden" name="action" value="register" />
|
<input type="hidden" name="action" value="register" />
|
||||||
{{ field::input(label="Username", name="username", autocomplete="username", autocorrect="off", autocapitalize="none", disabled=force_localpart, value=suggested_localpart) }}
|
{% if force_localpart %}
|
||||||
|
<div class="rounded-lg bg-grey-25 dark:bg-grey-450 p-4">
|
||||||
|
<div class="font-medium">Will use the following username</div>
|
||||||
|
<div class="font-mono">{{ suggested_localpart }}</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
{{ field::input(label="Username", name="username", autocomplete="username", autocorrect="off", autocapitalize="none") }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if suggested_email %}
|
{% if suggested_email %}
|
||||||
<div class="rounded-lg bg-grey-25 dark:bg-grey-450 p-4">
|
<div class="rounded-lg bg-grey-25 dark:bg-grey-450 p-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user