auch einzelnutzer können sich registrieren
This commit is contained in:
@@ -91,26 +91,36 @@ else
|
||||
Zurück zum Login
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
{
|
||||
@* ── Tab Navigation ── *@
|
||||
<MudStack Row="true" Justify="Justify.Center" Class="mb-4">
|
||||
<MudButton OnClick="@(() => SetTab(0))"
|
||||
Variant="@(_activeTab == 0 ? Variant.Filled : Variant.Text)"
|
||||
Color="Color.Primary"
|
||||
Style="min-width: 120px; border-radius: 20px;">
|
||||
Anmelden
|
||||
</MudButton>
|
||||
<MudButton OnClick="@(() => SetTab(1))"
|
||||
Variant="@(_activeTab == 1 ? Variant.Filled : Variant.Text)"
|
||||
Color="Color.Primary"
|
||||
Style="min-width: 120px; border-radius: 20px;">
|
||||
@(_tenantInfo.IsTenant ? "Registrieren" : "Firma registrieren")
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudDivider Class="mb-6" />
|
||||
} else {
|
||||
@* ── Header / Navigation ── *@
|
||||
@if (_activeTab == 2)
|
||||
{
|
||||
@* ── Back Button for Firm Registration ── *@
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Class="mb-4">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.ArrowBack" OnClick="@(() => SetTab(0))" Color="Color.Primary" />
|
||||
<MudText Typo="Typo.h6" Style="font-weight:700">Firma registrieren</MudText>
|
||||
</MudStack>
|
||||
<MudDivider Class="mb-6" />
|
||||
}
|
||||
else
|
||||
{
|
||||
@* ── Tab Navigation ── *@
|
||||
<MudStack Row="true" Justify="Justify.Center" Class="mb-4">
|
||||
<MudButton OnClick="@(() => SetTab(0))"
|
||||
Variant="@(_activeTab == 0 ? Variant.Filled : Variant.Text)"
|
||||
Color="Color.Primary"
|
||||
Style="min-width: 120px; border-radius: 20px;">
|
||||
Anmelden
|
||||
</MudButton>
|
||||
<MudButton OnClick="@(() => SetTab(1))"
|
||||
Variant="@(_activeTab == 1 ? Variant.Filled : Variant.Text)"
|
||||
Color="Color.Primary"
|
||||
Style="min-width: 120px; border-radius: 20px;">
|
||||
Registrieren
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
<MudDivider Class="mb-6" />
|
||||
}
|
||||
|
||||
@if (_activeTab == 0)
|
||||
{
|
||||
@@ -156,7 +166,7 @@ else
|
||||
</EditForm>
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
else if (_activeTab == 1)
|
||||
{
|
||||
@if (_tenantInfo.IsTenant)
|
||||
{
|
||||
@@ -211,61 +221,41 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
@* ── Firm Register Form ── *@
|
||||
@* ── Single User Register Form ── *@
|
||||
<MudStack Spacing="3">
|
||||
@if (_error != null)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Dense="true">@_error</MudAlert>
|
||||
}
|
||||
<EditForm Model="@_firmModel" OnValidSubmit="HandleRegisterFirm">
|
||||
<DataAnnotationsValidator />
|
||||
<EditForm Model="@_registerModel" OnValidSubmit="HandleSingleUserRegister">
|
||||
<MudStack Spacing="3">
|
||||
<MudTextField T="string"
|
||||
Label="Firmenname (z.B. Acme GmbH)"
|
||||
Variant="Variant.Outlined"
|
||||
@bind-Value="_firmModel.CompanyName"
|
||||
Required="true" />
|
||||
|
||||
<MudTextField T="string"
|
||||
Label="Subdomain"
|
||||
Variant="Variant.Outlined"
|
||||
HelperText="Nur Kleinbuchstaben, Zahlen & Bindestriche (z.B. acme)"
|
||||
@bind-Value="_firmModel.Subdomain"
|
||||
Required="true"
|
||||
Adornment="Adornment.End"
|
||||
AdornmentText="@GetDomainSuffix()" />
|
||||
|
||||
<MudDivider Class="my-2" />
|
||||
<MudText Typo="Typo.subtitle2" Style="font-weight:700;">Administrator-Konto</MudText>
|
||||
|
||||
<MudTextField T="string"
|
||||
Label="Benutzername"
|
||||
Variant="Variant.Outlined"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Person"
|
||||
@bind-Value="_firmModel.AdminUsername"
|
||||
@bind-Value="_registerModel.Username"
|
||||
Required="true"
|
||||
HelperText="Mindestens 3 Zeichen" />
|
||||
|
||||
<MudTextField T="string"
|
||||
Label="Passwort"
|
||||
Variant="Variant.Outlined"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Lock"
|
||||
InputType="InputType.Password"
|
||||
@bind-Value="_firmModel.AdminPassword"
|
||||
@bind-Value="_registerModel.Password"
|
||||
Required="true"
|
||||
HelperText="Mindestens 6 Zeichen" />
|
||||
|
||||
<MudTextField T="string"
|
||||
Label="Passwort wiederholen"
|
||||
Variant="Variant.Outlined"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Lock"
|
||||
InputType="InputType.Password"
|
||||
@bind-Value="_firmModel.ConfirmPassword"
|
||||
@bind-Value="_confirmPassword"
|
||||
Required="true" />
|
||||
|
||||
<input type="text" style="display: none;" tabindex="-1" autocomplete="off" @bind="_honeypot" />
|
||||
|
||||
<MudCheckBox @bind-Value="_acceptAgb" Color="Color.Secondary" Class="mt-1">
|
||||
<MudText Typo="Typo.body2">Ich akzeptiere die <a href="/agb" target="_blank" style="color: var(--mud-palette-secondary); text-decoration: underline; font-weight: 600;">AGB</a>.</MudText>
|
||||
</MudCheckBox>
|
||||
@@ -275,20 +265,112 @@ else
|
||||
Color="Color.Secondary"
|
||||
FullWidth="true"
|
||||
Size="Size.Large"
|
||||
StartIcon="@Icons.Material.Filled.Business"
|
||||
StartIcon="@Icons.Material.Filled.PersonAdd"
|
||||
Class="mt-2"
|
||||
Disabled="_loading || !_acceptAgb">
|
||||
@if (_loading)
|
||||
{
|
||||
<MudProgressCircular Size="Size.Small" Indeterminate="true" Class="mr-2" />
|
||||
}
|
||||
Firma registrieren
|
||||
Konto erstellen
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</EditForm>
|
||||
</MudStack>
|
||||
}
|
||||
}
|
||||
else if (_activeTab == 2)
|
||||
{
|
||||
@* ── Firm Register Form ── *@
|
||||
<MudStack Spacing="3">
|
||||
@if (_error != null)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Dense="true">@_error</MudAlert>
|
||||
}
|
||||
<EditForm Model="@_firmModel" OnValidSubmit="HandleRegisterFirm">
|
||||
<DataAnnotationsValidator />
|
||||
<MudStack Spacing="3">
|
||||
<MudTextField T="string"
|
||||
Label="Firmenname (z.B. Acme GmbH)"
|
||||
Variant="Variant.Outlined"
|
||||
@bind-Value="_firmModel.CompanyName"
|
||||
Required="true" />
|
||||
|
||||
<MudTextField T="string"
|
||||
Label="Subdomain"
|
||||
Variant="Variant.Outlined"
|
||||
HelperText="Nur Kleinbuchstaben, Zahlen & Bindestriche (z.B. acme)"
|
||||
@bind-Value="_firmModel.Subdomain"
|
||||
Required="true"
|
||||
Adornment="Adornment.End"
|
||||
AdornmentText="@GetDomainSuffix()" />
|
||||
|
||||
<MudDivider Class="my-2" />
|
||||
<MudText Typo="Typo.subtitle2" Style="font-weight:700;">Administrator-Konto</MudText>
|
||||
|
||||
<MudTextField T="string"
|
||||
Label="Benutzername"
|
||||
Variant="Variant.Outlined"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Person"
|
||||
@bind-Value="_firmModel.AdminUsername"
|
||||
Required="true"
|
||||
HelperText="Mindestens 3 Zeichen" />
|
||||
|
||||
<MudTextField T="string"
|
||||
Label="Passwort"
|
||||
Variant="Variant.Outlined"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Lock"
|
||||
InputType="InputType.Password"
|
||||
@bind-Value="_firmModel.AdminPassword"
|
||||
Required="true"
|
||||
HelperText="Mindestens 6 Zeichen" />
|
||||
|
||||
<MudTextField T="string"
|
||||
Label="Passwort wiederholen"
|
||||
Variant="Variant.Outlined"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Lock"
|
||||
InputType="InputType.Password"
|
||||
@bind-Value="_firmModel.ConfirmPassword"
|
||||
Required="true" />
|
||||
|
||||
<MudCheckBox @bind-Value="_acceptAgb" Color="Color.Secondary" Class="mt-1">
|
||||
<MudText Typo="Typo.body2">Ich akzeptiere die <a href="/agb" target="_blank" style="color: var(--mud-palette-secondary); text-decoration: underline; font-weight: 600;">AGB</a>.</MudText>
|
||||
</MudCheckBox>
|
||||
|
||||
<MudButton ButtonType="ButtonType.Submit"
|
||||
Variant="Variant.Filled"
|
||||
Color="Color.Secondary"
|
||||
FullWidth="true"
|
||||
Size="Size.Large"
|
||||
StartIcon="@Icons.Material.Filled.Business"
|
||||
Class="mt-2"
|
||||
Disabled="_loading || !_acceptAgb">
|
||||
@if (_loading)
|
||||
{
|
||||
<MudProgressCircular Size="Size.Small" Indeterminate="true" Class="mr-2" />
|
||||
}
|
||||
Firma registrieren
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</EditForm>
|
||||
</MudStack>
|
||||
}
|
||||
|
||||
@if (!_tenantInfo.IsTenant && _activeTab != 2)
|
||||
{
|
||||
<MudDivider Class="my-4" />
|
||||
<MudStack AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">
|
||||
Sie möchten Timetracker für Ihr Unternehmen nutzen?
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Primary" OnClick="@(() => SetTab(2))" StartIcon="@Icons.Material.Filled.Business">
|
||||
Eigene Firma registrieren
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
}
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
@@ -303,6 +385,7 @@ else
|
||||
private string _honeypot = "";
|
||||
private bool _acceptAgb;
|
||||
private bool _firmRegisteredSuccessfully;
|
||||
private string _confirmPassword = "";
|
||||
|
||||
private readonly AuthModel _loginModel = new();
|
||||
private readonly AuthModel _registerModel = new();
|
||||
@@ -432,6 +515,44 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleSingleUserRegister()
|
||||
{
|
||||
if (!_acceptAgb)
|
||||
{
|
||||
_error = "Du musst die AGB akzeptieren.";
|
||||
return;
|
||||
}
|
||||
if (_registerModel.Password != _confirmPassword)
|
||||
{
|
||||
_error = "Passwörter stimmen nicht überein.";
|
||||
return;
|
||||
}
|
||||
|
||||
_loading = true;
|
||||
_error = null;
|
||||
try
|
||||
{
|
||||
var (user, error) = await AuthService.RegisterAsync(_registerModel.Username, _registerModel.Password, _honeypot);
|
||||
if (user != null)
|
||||
{
|
||||
await JSRuntime.InvokeVoidAsync("localStorage.setItem", "showOnboarding", "true");
|
||||
Nav.NavigateTo("/", forceLoad: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_error = error ?? "Registrierung fehlgeschlagen.";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_error = $"Registrierungs Fehler: {ex.Message}";
|
||||
}
|
||||
finally
|
||||
{
|
||||
_loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleRegisterFirm()
|
||||
{
|
||||
if (!_acceptAgb)
|
||||
|
||||
Reference in New Issue
Block a user