hdong:Add flag CreateUserAutomatically to control user create in user/me .
This commit is contained in:
parent
d592621190
commit
3ec5055216
|
|
@ -7,4 +7,5 @@ public class AccountSetting
|
|||
/// </summary>
|
||||
public bool NewUserVerification { get; set; }
|
||||
public string[] AllowMultipleDeviceLoginUserIds { get; set; } = [];
|
||||
public bool CreateUserAutomatically { get; set; } = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using BotSharp.Abstraction.Users.Settings;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
|
@ -10,10 +11,12 @@ public class UserController : ControllerBase
|
|||
{
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly IUserService _userService;
|
||||
public UserController(IUserService userService, IServiceProvider services)
|
||||
private readonly AccountSetting _setting;
|
||||
public UserController(IUserService userService, IServiceProvider services, AccountSetting setting)
|
||||
{
|
||||
_services = services;
|
||||
_userService = userService;
|
||||
_setting = setting;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
|
|
@ -77,7 +80,7 @@ public class UserController : ControllerBase
|
|||
public async Task<UserViewModel> GetMyUserProfile()
|
||||
{
|
||||
var user = await _userService.GetMyProfile();
|
||||
if (user == null)
|
||||
if (user == null && _setting.CreateUserAutomatically)
|
||||
{
|
||||
var identiy = _services.GetRequiredService<IUserIdentity>();
|
||||
var accessor = _services.GetRequiredService<IHttpContextAccessor>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue