@page "/setup" @rendermode InteractiveServer @using CannedNet.Admin.Services @inject AdminAuthService AuthService @inject NavigationManager Navigation First-Time Setup

First-Time Setup

@if (completed) {
Owner account created!

You can now log in with your new admin account.

} else if (AuthService.HasAnyUser()) {
Admin accounts already exist. Go to login.
} else {

Create the initial owner account. This account will have full access and can create additional admin accounts.

@if (!string.IsNullOrEmpty(message)) {
@message
}
}
@code { private string username = ""; private string password = ""; private string confirmPassword = ""; private bool creating; private bool completed; private string? message; private async Task CreateOwner() { creating = true; message = null; try { if (string.IsNullOrWhiteSpace(username)) { message = "Username is required."; return; } if (string.IsNullOrWhiteSpace(password) || password.Length < 6) { message = "Password must be at least 6 characters."; return; } if (password != confirmPassword) { message = "Passwords do not match."; return; } if (AuthService.HasAnyUser()) { message = "Admin accounts already exist."; return; } if (AuthService.GetByUsername(username) != null) { message = "Username already taken."; return; } AuthService.CreateUser(username, password, isOwner: true); completed = true; } catch (Exception ex) { message = $"Error: {ex.Message}"; } finally { creating = false; } } }