feat: 添加用户、角色功能

This commit is contained in:
chenchun
2023-02-12 18:43:11 +08:00
parent bc42efe703
commit 158cab9f9b
22 changed files with 304 additions and 92 deletions

View File

@@ -1,4 +1,5 @@
using System;
using Mapster;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -103,6 +104,30 @@ namespace Yi.RBAC.Domain.Identity
return claims;
}
public async Task UpdatePasswordAsync(long userId, string newPassword, string oldPassword)
{
var user = await _repository.GetByIdAsync(userId);
if (!user.JudgePassword(oldPassword))
{
throw new UserFriendlyException("无效更新!新密码不能与老密码相同");
}
user.Password = newPassword;
user.BuildPassword();
await _repository.UpdateAsync(user);
}
public async Task<bool> RestPasswordAsync(long userId, string password)
{
var user = await _repository.GetByIdAsync(userId);
user.Id = userId;
user.Password = password;
user.BuildPassword();
return await _repository.UpdateAsync(user);
}
}
}