1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-26 12:55:17 +01:00

allow to disable user registration from env

This commit is contained in:
Kyle Spearrin 2017-08-28 07:50:57 -04:00
parent 5fa7321575
commit 417ac64ad2
3 changed files with 9 additions and 2 deletions

View File

@ -11,6 +11,7 @@ namespace Bit.Core
public virtual string LogDirectory { get; set; }
public virtual string LicenseDirectory { get; set; }
public virtual string PushRelayBaseUri { get; set; }
public virtual bool DisableUserRegistration { get; set; }
public virtual InstallationSettings Installation { get; set; } = new InstallationSettings();
public virtual BaseServiceUriSettings BaseServiceUri { get; set; } = new BaseServiceUriSettings();
public virtual SqlServerSettings SqlServer { get; set; } = new SqlServerSettings();

View File

@ -206,6 +206,11 @@ namespace Bit.Core.Services
public async Task<IdentityResult> RegisterUserAsync(User user, string masterPassword)
{
if(_globalSettings.DisableUserRegistration)
{
throw new BadRequestException("Registration has been disabled by the system administrator.");
}
var result = await base.CreateAsync(user, masterPassword);
if(result == IdentityResult.Success)
{

View File

@ -390,12 +390,13 @@ globalSettings__installation__id={_installationId}
globalSettings__installation__key={_installationKey}
globalSettings__yubico__clientId=REPLACE
globalSettings__yubico__key=REPLACE
globalSettings__mail__replyToEmail=hello@bitwarden.com
globalSettings__mail__replyToEmail=no-reply@{_domain}
globalSettings__mail__smtp__host=REPLACE
globalSettings__mail__smtp__username=REPLACE
globalSettings__mail__smtp__password=REPLACE
globalSettings__mail__smtp__ssl=true
globalSettings__mail__smtp__port=587");
globalSettings__mail__smtp__port=587
globalSettings__disableUserRegistration=false");
if(!_push)
{