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.Authentication
|
||||||
@using Microsoft.AspNetCore.Identity
|
@using Microsoft.AspNetCore.Identity
|
||||||
@using FWLAZ_Web.Data
|
@using FWLAZ_Web.Data
|
||||||
|
@using Microsoft.Extensions.Options
|
||||||
|
|
||||||
@inject SignInManager<IdentityUser> SignInManager
|
@inject SignInManager<IdentityUser> SignInManager
|
||||||
@inject ILogger<Login> Logger
|
@inject ILogger<Login> Logger
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IdentityRedirectManager RedirectManager
|
@inject IdentityRedirectManager RedirectManager
|
||||||
|
@inject IOptions<AppSettings> Config;
|
||||||
|
|
||||||
<PageTitle>Log in</PageTitle>
|
<PageTitle>Log in</PageTitle>
|
||||||
|
|
||||||
@ -45,9 +47,12 @@
|
|||||||
<p>
|
<p>
|
||||||
<a href="Account/ForgotPassword">Forgot your password?</a>
|
<a href="Account/ForgotPassword">Forgot your password?</a>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
@if (Config.Value.RegistrationEnabled)
|
||||||
<a href="@(NavigationManager.GetUriWithQueryParameters("Account/Register", new Dictionary<string, object?> { ["ReturnUrl"] = ReturnUrl }))">Register as a new user</a>
|
{
|
||||||
</p>
|
<p>
|
||||||
|
<a href="@(NavigationManager.GetUriWithQueryParameters("Account/Register", new Dictionary<string, object?> { ["ReturnUrl"] = ReturnUrl }))">Register as a new user</a>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
<p>
|
<p>
|
||||||
<a href="Account/ResendEmailConfirmation">Resend email confirmation</a>
|
<a href="Account/ResendEmailConfirmation">Resend email confirmation</a>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
@using Microsoft.AspNetCore.Identity
|
@using Microsoft.AspNetCore.Identity
|
||||||
@using Microsoft.AspNetCore.WebUtilities
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
@using FWLAZ_Web.Data
|
@using FWLAZ_Web.Data
|
||||||
|
@using Microsoft.Extensions.Options
|
||||||
|
|
||||||
@inject UserManager<IdentityUser> UserManager
|
@inject UserManager<IdentityUser> UserManager
|
||||||
@inject IUserStore<IdentityUser> UserStore
|
@inject IUserStore<IdentityUser> UserStore
|
||||||
@ -14,9 +15,17 @@
|
|||||||
@inject ILogger<Register> Logger
|
@inject ILogger<Register> Logger
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IdentityRedirectManager RedirectManager
|
@inject IdentityRedirectManager RedirectManager
|
||||||
|
@inject IOptions<AppSettings> Config;
|
||||||
|
|
||||||
|
|
||||||
<PageTitle>Register</PageTitle>
|
<PageTitle>Register</PageTitle>
|
||||||
|
|
||||||
|
@if (!Config.Value.RegistrationEnabled)
|
||||||
|
{
|
||||||
|
RedirectManager.RedirectTo("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
<h1>Register</h1>
|
<h1>Register</h1>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@ -6,9 +6,13 @@ using FWLAZ_Web.Objects;
|
|||||||
using FWLAZ_Web.Components.Account;
|
using FWLAZ_Web.Components.Account;
|
||||||
using Microsoft.AspNetCore.Components.Authorization;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using FWLAZ_Web;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// AppSettings auslesen
|
||||||
var connectionstring = builder.Configuration.GetConnectionString("QuizDB");
|
var connectionstring = builder.Configuration.GetConnectionString("QuizDB");
|
||||||
|
builder.Services.Configure<AppSettings>(builder.Configuration.GetSection(nameof(AppSettings)));
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
|
|||||||
@ -8,5 +8,8 @@
|
|||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"QuizDB": "Data Source=Data/quiz.db"
|
"QuizDB": "Data Source=Data/quiz.db"
|
||||||
},
|
},
|
||||||
|
"AppSettings": {
|
||||||
|
"RegistrationEnabled": true
|
||||||
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user