Setting eingebaut um umschalten zu können, ob Registrieren erlaubt ist
This commit is contained in:
parent
68ba7280c8
commit
626f6a88ce
7
FWLAZ_Web/AppSettings.cs
Normal file
7
FWLAZ_Web/AppSettings.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace FWLAZ_Web
|
||||
{
|
||||
public class AppSettings
|
||||
{
|
||||
public bool RegistrationEnabled { get; set; }
|
||||
}
|
||||
}
|
||||
@ -4,11 +4,13 @@
|
||||
@using Microsoft.AspNetCore.Authentication
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
@using FWLAZ_Web.Data
|
||||
@using Microsoft.Extensions.Options
|
||||
|
||||
@inject SignInManager<IdentityUser> SignInManager
|
||||
@inject ILogger<Login> Logger
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IdentityRedirectManager RedirectManager
|
||||
@inject IOptions<AppSettings> Config;
|
||||
|
||||
<PageTitle>Log in</PageTitle>
|
||||
|
||||
@ -45,9 +47,12 @@
|
||||
<p>
|
||||
<a href="Account/ForgotPassword">Forgot your password?</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="@(NavigationManager.GetUriWithQueryParameters("Account/Register", new Dictionary<string, object?> { ["ReturnUrl"] = ReturnUrl }))">Register as a new user</a>
|
||||
</p>
|
||||
@if (Config.Value.RegistrationEnabled)
|
||||
{
|
||||
<p>
|
||||
<a href="@(NavigationManager.GetUriWithQueryParameters("Account/Register", new Dictionary<string, object?> { ["ReturnUrl"] = ReturnUrl }))">Register as a new user</a>
|
||||
</p>
|
||||
}
|
||||
<p>
|
||||
<a href="Account/ResendEmailConfirmation">Resend email confirmation</a>
|
||||
</p>
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
@using Microsoft.AspNetCore.WebUtilities
|
||||
@using FWLAZ_Web.Data
|
||||
@using Microsoft.Extensions.Options
|
||||
|
||||
@inject UserManager<IdentityUser> UserManager
|
||||
@inject IUserStore<IdentityUser> UserStore
|
||||
@ -14,9 +15,17 @@
|
||||
@inject ILogger<Register> Logger
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IdentityRedirectManager RedirectManager
|
||||
@inject IOptions<AppSettings> Config;
|
||||
|
||||
|
||||
<PageTitle>Register</PageTitle>
|
||||
|
||||
@if (!Config.Value.RegistrationEnabled)
|
||||
{
|
||||
RedirectManager.RedirectTo("/");
|
||||
}
|
||||
|
||||
|
||||
<h1>Register</h1>
|
||||
|
||||
<div class="row">
|
||||
|
||||
@ -6,9 +6,13 @@ using FWLAZ_Web.Objects;
|
||||
using FWLAZ_Web.Components.Account;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using FWLAZ_Web;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// AppSettings auslesen
|
||||
var connectionstring = builder.Configuration.GetConnectionString("QuizDB");
|
||||
builder.Services.Configure<AppSettings>(builder.Configuration.GetSection(nameof(AppSettings)));
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorComponents()
|
||||
|
||||
@ -8,5 +8,8 @@
|
||||
"ConnectionStrings": {
|
||||
"QuizDB": "Data Source=Data/quiz.db"
|
||||
},
|
||||
"AppSettings": {
|
||||
"RegistrationEnabled": true
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user