优化注册服务
This commit is contained in:
@@ -10,10 +10,9 @@ using SqlSugar;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Common;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Service.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
|
||||
@@ -93,9 +93,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
[Log(Title = "修改密码", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult UpdatePwd(string oldPassword, string newPassword)
|
||||
{
|
||||
LoginUser loginUser = Framework.JwtUtil.GetLoginUser(HttpContext);
|
||||
|
||||
SysUser user = UserService.SelectUserById(loginUser.UserId);
|
||||
long userId = HttpContext.GetUId();
|
||||
SysUser user = UserService.SelectUserById(userId);
|
||||
string oldMd5 = NETCore.Encrypt.EncryptProvider.Md5(oldPassword);
|
||||
string newMd5 = NETCore.Encrypt.EncryptProvider.Md5(newPassword);
|
||||
|
||||
@@ -107,7 +106,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
{
|
||||
return ToResponse(ApiResult.Error("新密码不能和旧密码相同"));
|
||||
}
|
||||
if (UserService.ResetPwd(loginUser.UserId, newMd5.ToLower()) > 0)
|
||||
if (UserService.ResetPwd(userId, newMd5) > 0)
|
||||
{
|
||||
//TODO 更新缓存
|
||||
|
||||
@@ -127,12 +126,12 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
[Log(Title = "修改头像", BusinessType = BusinessType.UPDATE, IsSaveRequestData = false)]
|
||||
public async Task<IActionResult> Avatar([FromForm(Name = "picture")] IFormFile formFile)
|
||||
{
|
||||
LoginUser loginUser = Framework.JwtUtil.GetLoginUser(HttpContext);
|
||||
long userId = HttpContext.GetUId();
|
||||
if (formFile == null) throw new CustomException("请选择文件");
|
||||
|
||||
SysFile file = await FileService.SaveFileToLocal(hostEnvironment.WebRootPath, "", "avatar", HttpContext.GetName(), formFile);
|
||||
|
||||
UserService.UpdatePhoto(new SysUser() { Avatar = file.AccessUrl, UserId = loginUser.UserId });
|
||||
UserService.UpdatePhoto(new SysUser() { Avatar = file.AccessUrl, UserId = userId });
|
||||
return SUCCESS(new { imgUrl = file.AccessUrl });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user