新建用户默认授予Default角色

This commit is contained in:
Argo-Lenovo 2016-12-31 17:07:18 +08:00
parent 815fb08c5c
commit 34ea921d1f
2 changed files with 4 additions and 0 deletions

View File

@ -80,6 +80,7 @@ SET IDENTITY_INSERT [dbo].[UserGroup] OFF
DELETE FROM UserRole
SET IDENTITY_INSERT [dbo].[UserRole] ON
INSERT [dbo].[UserRole] ([ID], [UserID], [RoleID]) VALUES (1, 1, 1)
INSERT [dbo].[UserRole] ([ID], [UserID], [RoleID]) VALUES (2, 1, 2)
SET IDENTITY_INSERT [dbo].[UserRole] OFF
DELETE FROM NavigationRole

View File

@ -201,7 +201,10 @@ BEGIN
declare @approveTime datetime = null
if @userStatus = 0 set @approveTime = GETDATE()
if(@id = 0 and not exists (select 1 from Users Where UserName = @userName))
begin
Insert Into Users (UserName, [Password], PassSalt, DisplayName, RegisterTime, ApprovedTime, [Description]) values (@userName, @password, @passSalt, @displayName, GETDATE(), @approveTime, @description)
insert into UserRole (UserID, RoleID) select @@IDENTITY, ID from Roles where RoleName = N'Default'
end
else
Update Users set [Password] = @password, PassSalt = @passSalt, DisplayName = @displayName where ID = @id
end