Merge branch 'dev'

This commit is contained in:
Argo Zhang 2019-09-28 17:36:40 +08:00
commit 07126c3d09
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
4 changed files with 18 additions and 14 deletions

View File

@ -61,8 +61,7 @@ namespace Bootstrap.Admin
services.AddSignalR().AddJsonProtocalDefault();
services.AddSignalRExceptionFilterHandler<SignalRHub>((client, ex) => client.SendMessageBody(ex).ConfigureAwait(false));
services.AddResponseCompression();
// 兼容 QQ 浏览器兼容模式
services.AddBootstrapAdminAuthentication(configureCookies: ConfigureCookie).AddGitee(OAuthHelper.Configure).AddGitHub(OAuthHelper.Configure);
services.AddBootstrapAdminAuthentication().AddGitee(OAuthHelper.Configure).AddGitHub(OAuthHelper.Configure);
services.AddSwagger();
services.AddButtonAuthorization(MenuHelper.AuthorizateButtons);
services.AddBootstrapAdminBackgroundTask();
@ -124,11 +123,5 @@ namespace Bootstrap.Admin
app.UseSwagger(Configuration["SwaggerPathBase"].TrimEnd('/'));
app.UseMvcWithDefaultRoute();
}
private void ConfigureCookie(CookieAuthenticationOptions options)
{
var supportQQ = Configuration.GetValue("SupportQQBrowser", false);
if (supportQQ) options.Cookie.SameSite = SameSiteMode.None;
}
}
}

View File

@ -15,7 +15,6 @@
"ConnectionStrings": {
"ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa"
},
"SupportQQBrowser": false,
"DB": [
{
"Enabled": false,

View File

@ -80,11 +80,19 @@ namespace Bootstrap.DataAccess.MongoDB
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.UserName.ToLowerInvariant() == userName.ToLowerInvariant());
if (user != null)
{
// 用户所属角色
var role = RoleHelper.Retrieves();
roles.AddRange(role.Where(r => user.Roles.Any(rl => rl == r.Id)).Select(r => r.RoleName));
// 用户所属部门 部门所属角色
GroupHelper.Retrieves().Cast<Group>().Where(group => user.Groups.Any(g => g == group.Id)).ToList().ForEach(g =>
{
roles.AddRange(role.Where(r => g.Roles.Any(rl => rl == r.Id)).Select(r => r.RoleName));
});
if (roles.Count == 0) roles.Add("Default");
}
return roles;
return roles.Distinct();
}
/// <summary>

View File

@ -107,12 +107,15 @@ namespace Bootstrap.DataAccess.MongoDB
// 已经存在或者已经在新用户中了
if (UserHelper.RetrieveUserByUserName(new GenericIdentity(user.UserName)) != null || UserHelper.RetrieveNewUsers().Any(u => u.UserName == user.UserName)) return false;
DbManager.Users.InsertOne(new User()
user.PassSalt = LgbCryptography.GenerateSalt();
user.Password = LgbCryptography.ComputeHash(user.Password, user.PassSalt);
var newUser = new User()
{
UserName = user.UserName,
DisplayName = user.DisplayName,
PassSalt = LgbCryptography.GenerateSalt(),
Password = LgbCryptography.ComputeHash(user.Password, user.PassSalt),
PassSalt = user.PassSalt,
Password = user.Password,
RegisterTime = DateTime.Now,
ApprovedTime = user.ApprovedTime,
ApprovedBy = user.ApprovedBy,
@ -121,7 +124,8 @@ namespace Bootstrap.DataAccess.MongoDB
Icon = user.Icon,
Description = user.Description,
IsReset = 0
});
};
DbManager.Users.InsertOne(newUser);
user.Id = DbManager.Users.Find(r => r.UserName == user.UserName).FirstOrDefault().Id;
return true;
}