homepage/templates/user/auth/signup_inner.tmpl

79 lines
3.3 KiB
Go Template

<div class="ui container fluid{{if .LinkAccountMode}} icon{{end}}">
<h4 class="ui top attached header center">
{{if .LinkAccountMode}}
{{ctx.Locale.Tr "auth.oauth_signup_title"}}
{{else}}
{{ctx.Locale.Tr "sign_up"}}
{{end}}
</h4>
<div class="ui attached segment">
<form class="ui form" action="{{.SignUpLink}}" method="post" data-email-free-signup>
{{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeRegister)}}
{{template "base/alert" .}}
{{end}}
{{if .DisableRegistration}}
<p>{{.DisableRegistrationReason}}</p>
{{else}}
{{template "custom/signup_top"}}
<div class="required field {{if and (.Err_UserName) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeRegister))}}error{{end}}">
<label for="user_name">{{ctx.Locale.Tr "username"}}</label>
<input id="user_name" type="text" name="user_name" value="{{.user_name}}" autofocus required autocorrect="off" autocapitalize="none">
</div>
<input id="email" name="email" type="hidden" value="{{.email}}" data-generated-email>
<div class="ui info message">
Электронная почта не требуется. Forgejo сохранит внутренний технический адрес и не будет отправлять на него письма.
</div>
{{if not .DisablePassword}}
<div class="required field {{if and (.Err_Password) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeRegister))}}error{{end}}">
<label for="password">{{ctx.Locale.Tr "password"}}</label>
<input id="password" name="password" type="password" value="{{.password}}" autocomplete="new-password" required>
</div>
<div class="required field {{if and (.Err_Password) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeRegister))}}error{{end}}">
<label for="retype">{{ctx.Locale.Tr "re_type"}}</label>
<input id="retype" name="retype" type="password" value="{{.retype}}" autocomplete="new-password" required>
</div>
{{end}}
{{template "user/auth/captcha" .}}
<div class="inline field">
<button class="ui primary button tw-w-full">
{{if .LinkAccountMode}}
{{ctx.Locale.Tr "auth.oauth_signup_submit"}}
{{else}}
{{ctx.Locale.Tr "auth.create_new_account"}}
{{end}}
</button>
</div>
{{end}}
{{template "user/auth/oauth_container" .}}
</form>
</div>
</div>
{{if not .LinkAccountMode}}
<div class="ui container fluid">
<div class="ui attached segment header top tw-flex tw-flex-col tw-items-center">
<div class="field">
{{ctx.Locale.Tr "auth.hint_login" (printf "%s/user/login" AppSubUrl)}}
</div>
</div>
</div>
{{end}}
<script type="module">
const form = document.querySelector('form[data-email-free-signup]');
const username = form?.querySelector('input[name="user_name"]');
const email = form?.querySelector('input[data-generated-email]');
const updateGeneratedEmail = () => {
const localPart = username?.value.trim().toLowerCase() || '';
if (email && /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/.test(localPart)) {
email.value = `${localPart}@users.noreply.git.zapret.moe`;
}
};
username?.addEventListener('input', updateGeneratedEmail);
form?.addEventListener('submit', updateGeneratedEmail);
updateGeneratedEmail();
</script>