Merge commit 'refs/pull/35/head' of https://gitee.com/izory/ZrAdminNetCore into net7.0
This commit is contained in:
commit
36de53cbcc
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using NETCore.Encrypt;
|
||||||
using UAParser;
|
using UAParser;
|
||||||
using ZR.Admin.WebApi.Extensions;
|
using ZR.Admin.WebApi.Extensions;
|
||||||
using ZR.Admin.WebApi.Filters;
|
using ZR.Admin.WebApi.Filters;
|
||||||
@ -58,7 +59,9 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
roleService = sysRoleService;
|
roleService = sysRoleService;
|
||||||
this.jwtSettings = jwtSettings.Value;
|
this.jwtSettings = jwtSettings.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RSA私钥
|
||||||
|
private static string _privateKey;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 登录
|
/// 登录
|
||||||
@ -77,7 +80,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
|
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
|
||||||
}
|
}
|
||||||
|
// RSA解密
|
||||||
|
loginBody.Password = EncryptProvider.RSADecryptWithPem(_privateKey, loginBody.Password);
|
||||||
var user = sysLoginService.Login(loginBody, RecordLogInfo(httpContextAccessor.HttpContext));
|
var user = sysLoginService.Login(loginBody, RecordLogInfo(httpContextAccessor.HttpContext));
|
||||||
|
|
||||||
List<SysRole> roles = roleService.SelectUserRoleListByUserId(user.UserId);
|
List<SysRole> roles = roleService.SelectUserRoleListByUserId(user.UserId);
|
||||||
@ -210,5 +214,19 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
}
|
}
|
||||||
return ToResponse(ResultCode.CUSTOM_ERROR, "注册失败,请联系管理员");
|
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