web 用户处理推进
This commit is contained in:
parent
5d44174d01
commit
ca0880e256
28
AxibugEmuOnline.Web/Common/Helper.cs
Normal file
28
AxibugEmuOnline.Web/Common/Helper.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using AxibugProtobuf;
|
||||
|
||||
namespace AxibugEmuOnline.Web.Common
|
||||
{
|
||||
public class Helper
|
||||
{
|
||||
public static bool TryDecrypToken(string tokenStr, out Protobuf_Token_Struct tokenData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tokenStr) || string.IsNullOrEmpty(tokenStr.Trim()))
|
||||
{
|
||||
tokenData = null;
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
byte[] encryptData = Convert.FromBase64String(tokenStr.Trim());
|
||||
byte[] decryptData = AESHelper.Decrypt(encryptData);
|
||||
tokenData = ProtoBufHelper.DeSerizlize<Protobuf_Token_Struct>(decryptData);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
tokenData = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
60
AxibugEmuOnline.Web/Controllers/UserController.cs
Normal file
60
AxibugEmuOnline.Web/Controllers/UserController.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace AxibugEmuOnline.Web.Controllers
|
||||
{
|
||||
public class UserController : Controller
|
||||
{
|
||||
private readonly ILogger<UserController> _logger;
|
||||
|
||||
public UserController(ILogger<UserController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
//public JsonResult CheckTokenState(string tokenStr,int type)
|
||||
//{
|
||||
// long UID = 0;
|
||||
// if (Helper.TryDecrypToken(tokenStr, out Protobuf_Token_Struct tokenData))
|
||||
// UID = tokenData.UID;
|
||||
|
||||
// if (UID < 0)
|
||||
// return new JsonResult(new CheckTokenState_Resp(){ code = -1,msg = "token错误"});
|
||||
// string query;
|
||||
// using (MySqlConnection conn = SQLRUN.GetConn("RomList"))
|
||||
// {
|
||||
// //设置默认名字
|
||||
// query = "select uid,account,mail from users where uid = ?uid ";
|
||||
// using (var command = new MySqlCommand(query, conn))
|
||||
// {
|
||||
// // 设置参数值
|
||||
// command.Parameters.AddWithValue("?uid", UID);// 执行查询并处理结果
|
||||
// using (var reader = command.ExecuteReader())
|
||||
// {
|
||||
// while (reader.Read())
|
||||
// {
|
||||
// uid = reader.GetInt64(0);
|
||||
// Account = reader.IsDBNull(1) ? string.Empty : reader.GetString(1);
|
||||
// mail = reader.IsDBNull(2) ? string.Empty : reader.GetString(2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (type == 0)
|
||||
// {
|
||||
// }
|
||||
//}
|
||||
|
||||
class CheckTokenState_Resp
|
||||
{
|
||||
public int code { get; set; }
|
||||
public string msg { get; set; }
|
||||
public string uri { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user