diff --git a/UACloudLibraryServer/Areas/Identity/Pages/Account/Register.cshtml b/UACloudLibraryServer/Areas/Identity/Pages/Account/Register.cshtml index 99b730f4..95a8546e 100644 --- a/UACloudLibraryServer/Areas/Identity/Pages/Account/Register.cshtml +++ b/UACloudLibraryServer/Areas/Identity/Pages/Account/Register.cshtml @@ -8,60 +8,75 @@
-
-

Create a new account.

-
-
-
- - - -
-
- - - -
-
- - - -
- -
-
-
-
-

Use another service to register.

-
- @{ - if ((Model.ExternalLogins?.Count ?? 0) == 0) - { -
-

- There are no external authentication services configured. See this article - about setting up this ASP.NET application to support logging in via external services. -

-
- } - else - { -
+ @{ + if (Model.AllowSelfRegistration) + { +
+

+ +

Create a new account.

+
+
+
+ + + +
+
+ + + +
+
+ + + +
+ + +
+ } + else + { +
+

Creation of local accounts is currently unavailable.

+
+ } + } +
+
+

Use another service to register.

+
+ @{ + if ((Model.ExternalLogins?.Count ?? 0) == 0) + {

- @foreach (var provider in Model.ExternalLogins!) - { - - } + There are no external authentication services configured. See this + article + about setting up this ASP.NET application to support logging in via external services + .

- + } + else + { +
+
+

+ @foreach (var provider in Model.ExternalLogins!) + { + + } +

+
+
+ } } - } -
+
+
- -@section Scripts { - -} + @section Scripts { + + } diff --git a/UACloudLibraryServer/Areas/Identity/Pages/Account/Register.cshtml.cs b/UACloudLibraryServer/Areas/Identity/Pages/Account/Register.cshtml.cs index 77b628f9..b170b461 100644 --- a/UACloudLibraryServer/Areas/Identity/Pages/Account/Register.cshtml.cs +++ b/UACloudLibraryServer/Areas/Identity/Pages/Account/Register.cshtml.cs @@ -10,6 +10,7 @@ using System.Text.Encodings.Web; using System.Threading; using System.Threading.Tasks; +using Castle.Core.Configuration; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.UI.Services; @@ -17,6 +18,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Configuration; namespace Opc.Ua.Cloud.Library.Areas.Identity.Pages.Account { @@ -28,13 +30,15 @@ public class RegisterModel : PageModel private readonly IUserEmailStore _emailStore; private readonly ILogger _logger; private readonly IEmailSender _emailSender; + public bool AllowSelfRegistration { get; set; } public RegisterModel( UserManager userManager, IUserStore userStore, SignInManager signInManager, ILogger logger, - IEmailSender emailSender) + IEmailSender emailSender, + Microsoft.Extensions.Configuration.IConfiguration configuration) { _userManager = userManager; _userStore = userStore; @@ -42,6 +46,7 @@ public RegisterModel( _signInManager = signInManager; _logger = logger; _emailSender = emailSender; + AllowSelfRegistration = configuration.GetValue(nameof(AllowSelfRegistration)) == true; } ///