Merge commit 'refs/pull/35/head' of https://gitee.com/izory/ZrAdminNetCore into net7.0

This commit is contained in:
不做码农 2023-06-17 16:05:49 +08:00
commit 36de53cbcc

View File

@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using NETCore.Encrypt;
using UAParser;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
@ -59,6 +60,8 @@ namespace ZR.Admin.WebApi.Controllers.System
this.jwtSettings = jwtSettings.Value;
}
// RSA私钥
private static string _privateKey;
/// <summary>
/// 登录
@ -77,7 +80,8 @@ namespace ZR.Admin.WebApi.Controllers.System
{
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
}
// RSA解密
loginBody.Password = EncryptProvider.RSADecryptWithPem(_privateKey, loginBody.Password);
var user = sysLoginService.Login(loginBody, RecordLogInfo(httpContextAccessor.HttpContext));
List<SysRole> roles = roleService.SelectUserRoleListByUserId(user.UserId);
@ -210,5 +214,19 @@ namespace ZR.Admin.WebApi.Controllers.System
}
return ToResponse(ResultCode.CUSTOM_ERROR, "注册失败,请联系管理员");
}
/// <summary>
/// 获取RSA公钥和密钥
/// </summary>
/// <returns></returns>
[HttpGet("getRsaKey")]
public IActionResult GetRsaKey()
{
var (publicPem, privatePem) = EncryptProvider.RSAToPem(true);
_privateKey = privatePem;
return SUCCESS(new {
PublicKey = publicPem
});
}
}
}