Auto approve users created when approval is not required
parent
99f8b6d4f5
commit
0b7383b2ae
|
@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using LANCommander.Services;
|
||||
|
||||
namespace LANCommander.Areas.Identity.Pages.Account
|
||||
{
|
||||
|
@ -106,12 +107,20 @@ namespace LANCommander.Areas.Identity.Pages.Account
|
|||
|
||||
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
|
||||
{
|
||||
var settings = SettingService.GetSettings();
|
||||
|
||||
returnUrl ??= Url.Content("~/");
|
||||
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var user = CreateUser();
|
||||
|
||||
if (!settings.Authentication.RequireApproval)
|
||||
{
|
||||
user.Approved = false;
|
||||
user.ApprovedOn = DateTime.Now;
|
||||
}
|
||||
|
||||
await _userStore.SetUserNameAsync(user, Input.UserName, CancellationToken.None);
|
||||
var result = await _userManager.CreateAsync(user, Input.Password);
|
||||
|
||||
|
|
Loading…
Reference in New Issue