Merge pull request #442 from Moonlight-Panel/v2_ChangeArchitecture_FirstUserAdmin
Implemented first user admin feature
This commit is contained in:
@@ -44,6 +44,8 @@ public class AppConfiguration
|
||||
public string? AuthorizationEndpoint { get; set; }
|
||||
public string? AccessEndpoint { get; set; }
|
||||
public string? AuthorizationRedirect { get; set; }
|
||||
|
||||
public bool FirstUserAdmin { get; set; } = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -278,9 +278,18 @@ public class OAuth2Controller : Controller
|
||||
{
|
||||
Username = username,
|
||||
Email = email,
|
||||
Password = HashHelper.Hash(password)
|
||||
Password = HashHelper.Hash(password),
|
||||
};
|
||||
|
||||
if (Configuration.Authentication.OAuth2.FirstUserAdmin)
|
||||
{
|
||||
var userCount = await UserRepository.Get().CountAsync();
|
||||
|
||||
if (userCount == 0)
|
||||
user.PermissionsJson = "[\"*\"]";
|
||||
|
||||
}
|
||||
|
||||
return await UserRepository.Add(user);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user