4.7 KiB · text History 60fbb92
{% extends "root.html" %}

{% block content %}
<div class="hero min-h-[70vh]">
    <div class="hero-content flex-col lg:flex-row-reverse">
        <div class="text-center lg:text-left">
            <h1 class="text-5xl font-bold">Register</h1>
            <p class="py-6">Create your {{ app_name }} account.</p>
            {% if invite_token %}
            <div class="alert alert-success">
                <i class="fas fa-envelope-open-text"></i>
                <span>You're using an invite link — the token is filled in below.</span>
            </div>
            {% endif %}
            {% if error %}
            <div class="alert alert-error mt-4" role="alert" data-register-error>
                <i class="fas fa-circle-exclamation"></i>
                <span>{{ error }}</span>
            </div>
            {% endif %}
        </div>
        <div class="card shrink-0 w-full max-w-sm shadow-2xl bg-base-100">
            {% if providers and invite_token %}
            <div class="card-body pb-0">
                {% for p in providers %}
                <a class="btn btn-secondary w-full" data-oidc-provider="{{ p.id }}" hx-boost="false"
                   href="{{ p.login_url }}?invite={{ invite_token|urlencode }}">
                    <i class="fas fa-key mr-2"></i> {{ p.label|replace("Sign in", "Sign up") }}
                </a>
                {% endfor %}
                <div class="divider">or with a password</div>
            </div>
            {% endif %}
            <form class="card-body" action="/auth/register" method="post" hx-boost="false">
                <div class="form-control">
                    <label class="label"><span class="label-text">Username</span></label>
                    <input type="text" name="username" placeholder="Choose a username" class="input input-bordered" value="{{ username or '' }}"
                           minlength="3" maxlength="32" pattern="[A-Za-z0-9_.\-]+" title="3 to 32 letters, digits, dots, dashes or underscores" required autofocus/>
                </div>
                <div class="form-control">
                    <label class="label"><span class="label-text">Email</span></label>
                    <input type="email" name="email" placeholder="you@example.com" class="input input-bordered" value="{{ email or '' }}" required/>
                </div>
                <div class="form-control">
                    <label class="label"><span class="label-text">Password</span></label>
                    <input type="password" name="password" placeholder="At least 8 characters" class="input input-bordered" minlength="8" required/>
                </div>
                <div class="form-control">
                    <label class="label"><span class="label-text">Confirm password</span></label>
                    <input type="password" name="confirm_password" placeholder="Confirm password" class="input input-bordered" required/>
                </div>
                {# Open registration needs no invite, so no field unless one came
                   in the link. Closed, the field is required. #}
                {% if invite_token or not registration_open %}
                <div class="form-control">
                    <label class="label"><span class="label-text">Invite token</span></label>
                    <input type="text" name="registration_token" placeholder="Your invite token"
                           class="input input-bordered{% if invite_token %} input-disabled{% endif %}"
                           value="{{ invite_token or '' }}"
                           {% if invite_token %}readonly{% endif %} required/>
                </div>
                {% endif %}
                {# Open sign-up's guards (src/registration.rs): when the form was
                   served, and a field people never see. #}
                <input type="hidden" name="stamp" value="{{ stamp }}"/>
                <div aria-hidden="true" style="position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden">
                    <label>Website <input type="text" name="website" tabindex="-1" autocomplete="off" value=""/></label>
                </div>
                <p class="text-xs opacity-60 mt-2">We'll email you a link to verify your address. Until then you can read but not post.</p>
                <div class="form-control mt-4">
                    <button class="btn btn-primary" type="submit"><i class="fas fa-user-plus mr-2"></i> Register</button>
                </div>
                <div class="text-center mt-4">
                    <p class="text-sm">Already have an account? <a href="/login" class="link link-primary">Log in</a></p>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}