@page "/join" @inherits LocalizableComponentBase @Localizer["Join with an invitation"] @* A new login through a group's invitation (PrivaPub's /clientapi/user/invitation/signup): sign-up is otherwise closed, so this is how everyone but the first administrator arrives. Its first persona joins the group. A group's page links here with the code (?code=). *@
@if (CascadingState.IsSignedIn) {

@Localizer["You are signed in"]

@Localizer["A persona of yours joins a group by its invitation in Groups."]

@Localizer["Groups"]
} else {

@Localizer["Join with an invitation"]

@Localizer["A group's invitation makes your login here, and your first persona joins the group."]

@Localizer["Your login"] @Localizer["Your first persona"]

@Localizer["Others see your personas, never your login."]

@@ @if (isWorking) { } @Localizer["Join"] @Localizer["I have a login: sign in"]
}
@code { [Inject] AuthService AuthService { get; set; } readonly InvitationLoginForm form = new(); string repeatedPassword; string error; bool isWorking; [SupplyParameterFromQuery] public string Code { get; set; } protected override void OnInitialized() { form.InvitationCode = Code?.Trim(); IsLoading = false; } async Task SignUp() { error = default; if (form.Password != repeatedPassword) { error = Localizer["The two passwords don't match."]; return; } isWorking = true; form.InvitationCode = form.InvitationCode?.Trim(); form.InvitationPassword = string.IsNullOrEmpty(form.InvitationPassword) ? null : form.InvitationPassword; form.AvatarUserName = form.AvatarUserName?.Trim().TrimStart('@').ToLowerInvariant(); var result = await AuthService.Join(form); if (result.IsInvalid) { isWorking = false; error = result.ErrorMessage; return; } await CascadingState.LoadSession(); isWorking = false; Toast.AddResponseSuccess(Localizer["Welcome: your persona is in the group."]); Navigation.NavigateTo(""); } }