diff --git a/src/web/pages/account/register.rs b/src/web/pages/account/register.rs index e53f8be0c..1c25d6ca7 100644 --- a/src/web/pages/account/register.rs +++ b/src/web/pages/account/register.rs @@ -37,6 +37,7 @@ pub(crate) fn build() -> Router { template! { struct Register use "register.html.j2" { server_name: OwnedServerName, + is_first_run: bool, body: RegisterBody } } @@ -171,6 +172,7 @@ async fn route_register( return response!(Register::new( context, services.globals.server_name().to_owned(), + services.firstrun.is_first_run(), RegisterBody::Unavailable )); } @@ -195,6 +197,7 @@ async fn route_register( return response!(Register::new( context, services.globals.server_name().to_owned(), + services.firstrun.is_first_run(), RegisterBody::UsernamePrompt { allow_federation: services.config.allow_federation, trusted_flow_status, @@ -245,7 +248,12 @@ async fn route_register( } }; - response!(Register::new(context, services.globals.server_name().to_owned(), body)) + response!(Register::new( + context, + services.globals.server_name().to_owned(), + services.firstrun.is_first_run(), + body + )) } template! { @@ -555,7 +563,7 @@ pub(super) async fn registration_flow_status( .as_ref() .is_some_and(|smtp| smtp.require_email_for_registration); - if !allow_registration { + if !allow_registration || services.firstrun.is_first_run() { UntrustedFlowStatus::Unavailable } else if services.config.recaptcha_private_site_key.is_some() || require_email { UntrustedFlowStatus::Available { require_email } diff --git a/src/web/pages/oauth/grant.rs b/src/web/pages/oauth/grant.rs index 2154e32d4..4075f8e39 100644 --- a/src/web/pages/oauth/grant.rs +++ b/src/web/pages/oauth/grant.rs @@ -13,7 +13,7 @@ extract::{Expect, PostForm}, pages::{ GET_POST, Result, TemplateContext, - account::register::RegisterQuery, + account::register::{RegisterQuery, RequestedRegistrationFlow}, components::{Avatar, AvatarType, ClientScopes}, }, response, @@ -49,17 +49,24 @@ async fn route_authorization_code( let user_id = if let Some(user) = user.into_session() { user.user_id } else { + let is_first_run = services.firstrun.is_first_run(); let next = LoginTarget::AuthorizationCode(query.clone()); let uri = if query .prompt .is_some_and(|prompt| matches!(prompt, Prompt::Create)) + || is_first_run { format!( "{}/account/register/?{}", ROUTE_PREFIX, serde_urlencoded::to_string(RegisterQuery { next: Some(next), + flow: if is_first_run { + Some(RequestedRegistrationFlow::Trusted) + } else { + None + }, ..Default::default() }) .unwrap() diff --git a/src/web/pages/templates/register.html.j2 b/src/web/pages/templates/register.html.j2 index 2b94e69df..a16d0d50a 100644 --- a/src/web/pages/templates/register.html.j2 +++ b/src/web/pages/templates/register.html.j2 @@ -12,7 +12,9 @@ Sign up {%- block content -%}

- {% if let RegisterBody::UsernamePrompt { next, .. } = body && next.is_some() %} + {% if is_first_run %} + Finish setting up + {% else if let RegisterBody::UsernamePrompt { next, .. } = body && next.is_some() %} Sign up to continue {% else %} Sign up @@ -80,6 +82,11 @@ Sign up {% let validation_errors = validation_errors.clone() %} {% let field_errors = validation_errors.field_errors() %}
+ {% if is_first_run %} +

+ To finish setting up your server, choose a username and password for your account. +

+ {% endif %}

@@ -94,9 +101,11 @@ Sign up {{ form::errors(field_errors, std::borrow::Cow::Borrowed("username")) }} Note: Your username cannot be changed after you create your account.

-

- Just a few more details to finish creating your account. -

+ {% if !is_first_run %} +

+ Just a few more details to finish creating your account. +

+ {% endif %}

@@ -140,6 +149,9 @@ Sign up

+ {% if is_first_run %} + Check the server console to find the registration token. + {% endif %} {{ form::errors(field_errors, std::borrow::Cow::Borrowed("registration_token")) }}

{% endif %} @@ -157,14 +169,16 @@ Sign up I agree to the {{ document.name }} {% endfor %} - All policy links will open in a new tab. + All policy links will open in a new tab.

{% endif %}
{% endmatch %} - + {% if !is_first_run %} + + {% endif %}

{%- endblock -%}