登录增加获取RSA密钥接口,登录接口增加密码解密
This commit is contained in:
parent
0842d1b4ec
commit
f767752aa4
@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user