fix: 修复 EFCore 创建用户时不创建默认角色
This commit is contained in:
parent
32d74ea81a
commit
76126b05d1
|
@ -306,6 +306,7 @@ public class UserService : IUser
|
||||||
Password = pwd
|
Password = pwd
|
||||||
};
|
};
|
||||||
dbcontext.Add(user);
|
dbcontext.Add(user);
|
||||||
|
ret = dbcontext.SaveChanges() > 0;
|
||||||
// 授权 Default 角色
|
// 授权 Default 角色
|
||||||
dbcontext.Database.ExecuteSqlRaw("insert into UserRole (UserID, RoleID) select ID, (select ID from Roles where RoleName = 'Default') RoleId from Users where UserName = {0}", userName);
|
dbcontext.Database.ExecuteSqlRaw("insert into UserRole (UserID, RoleID) select ID, (select ID from Roles where RoleName = 'Default') RoleId from Users where UserName = {0}", userName);
|
||||||
ret = dbcontext.SaveChanges() > 0;
|
ret = dbcontext.SaveChanges() > 0;
|
||||||
|
|
Loading…
Reference in New Issue