server/aspnetapp/Controllers/WebUI/LoginController.cs

(开头部分) 12KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using aspnetapp.Helper;
using aspnetapp.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;

namespace aspnetapp.Controllers.WebUI
{
    public class LoginController : Controller
    {
        private readonly CounterContext _context;

        public LoginController(CounterContext context)
        {
            _context = context;
        }


        //修改密码
        public IActionResult PWD()
        {
            return View();
        }
        [HttpPost]
        public async Task<IActionResult> PWDAsync(string pw1, string pw2)
        {
            var ip = Request.HttpContext.Connection.RemoteIpAddress.ToString();
            var thisUser = default(SysUserEntity);
            var value = HttpContext.Session.GetString("sysu");
            if (!String.IsNullOrEmpty(value))
            {
                thisUser = System.Text.Json.JsonSerializer.Deserialize<SysUserEntity>(value);
            }
            if (!string.IsNullOrEmpty(pw1) && !string.IsNullOrEmpty(pw2))
            {
                if (pw1 == pw2)
                {
                    //base64解密
                    pw1 = Md5Helper.DecodeBase64(pw1);
                    string pwd = new Md5Helper().SM3Encrypt32(pw1);
                    thisUser.PassWord = pwd;
                    thisUser.PwdSetDate = DateTime.Now;
                    _context.SysUsers.Update(thisUser);
                    await _context.SaveChangesAsync().ConfigureAwait(false);

                    await LogHelper.InsertLogAsync(_context, new LogEntity
                    {
                        Createdate = DateTime.Now,
                        LogContent = "修改密码成功",
                        LogType = (int)EnumCode.LogType.修改密码,
                        LogUser = thisUser.LoginName,
                        LogIP = ip
                    }).ConfigureAwait(false);
                    TempData["Message"] = "修改密码成功";
                }
                else
                {
                    await LogHelper.InsertLogAsync(_context, new LogEntity
                    {
                        Createdate = DateTime.Now,
                        LogContent = "修改密码失败",
后面还有 254 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。