Commit 36c8aed5 by ryun

创建账号设置默认角色

parent 1041a2bf
...@@ -173,13 +173,16 @@ public class OAuthService : IAutoInjection ...@@ -173,13 +173,16 @@ public class OAuthService : IAutoInjection
public UserIdentity GetOrInitUserInfo(OAuthUserInfoResponse userData) public UserIdentity GetOrInitUserInfo(OAuthUserInfoResponse userData)
{ {
var userId = 0; var userId = 0;
var user = _userRepository.GetEntity(w => w.Login == userData.name); var user = _userRepository.GetEntity(w => w.Login == userData.desc);
if (user != null) if (user != null)
{ {
userId = user.ID; userId = user.ID;
} }
else else
{ {
var roleid = _configuration.GetValue("oauth2:default_roleid", $"{(int)Role.绩效查询}");
var roleIds = Array.ConvertAll(roleid.Split(",", StringSplitOptions.RemoveEmptyEntries), item => int.Parse(item));
var mail = _configuration.GetValue("oauth2:default_mail", "{0}@oauth.com"); var mail = _configuration.GetValue("oauth2:default_mail", "{0}@oauth.com");
var password = _configuration.GetValue("oauth2:default_password", "123456"); var password = _configuration.GetValue("oauth2:default_password", "123456");
var hosid = _configuration.GetValue("oauth2:default_hosid", 0); var hosid = _configuration.GetValue("oauth2:default_hosid", 0);
...@@ -188,15 +191,15 @@ public UserIdentity GetOrInitUserInfo(OAuthUserInfoResponse userData) ...@@ -188,15 +191,15 @@ public UserIdentity GetOrInitUserInfo(OAuthUserInfoResponse userData)
var userRequest = new UserRequest var userRequest = new UserRequest
{ {
Login = userData.name + Guid.NewGuid().ToString("N"), Login = userData.desc,
RealName = userData.name, RealName = userData.name,
Password = PwdHelper.MD5(password), Password = PwdHelper.MD5(password),
HosIDArray = new int[] { hosid }, HosIDArray = new int[] { hosid },
RoleArr = new int[] { (int)Role.绩效查询 }, RoleArr = roleIds,
States = (int)States.Enabled, States = (int)States.Enabled,
Remark = JsonHelper.Serialize(userData), Remark = JsonHelper.Serialize(userData),
Department = "", Department = "",
Mail = string.Format(mail, userData.name), Mail = string.Format(mail, userData.desc),
}; };
userId = _userService.InsertUser(userRequest, -1001).UserID; userId = _userService.InsertUser(userRequest, -1001).UserID;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment