mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-06-05 23:50:14 +08:00
feat(auth): add configuration options for user registration and anonymous image hosting
This commit is contained in:
@@ -9,7 +9,7 @@ using Foxel.Services.Configuration;
|
||||
namespace Foxel.Controllers;
|
||||
|
||||
[Route("api/auth")]
|
||||
public class AuthController(IAuthService authService) : BaseApiController
|
||||
public class AuthController(IAuthService authService, IConfigService configuration) : BaseApiController
|
||||
{
|
||||
[HttpPost("register")]
|
||||
public async Task<ActionResult<BaseResult<AuthResponse>>> Register([FromBody] RegisterRequest request)
|
||||
@@ -19,6 +19,13 @@ public class AuthController(IAuthService authService) : BaseApiController
|
||||
return Error<AuthResponse>("请求数据无效");
|
||||
}
|
||||
|
||||
// 检查是否允许新用户注册
|
||||
var enableRegistration = configuration["AppSettings:EnableRegistration"];
|
||||
if (string.Equals(enableRegistration, "false", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return Error<AuthResponse>("新用户注册功能已关闭");
|
||||
}
|
||||
|
||||
var (success, message, user) = await authService.RegisterUserAsync(request);
|
||||
if (!success)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user