RolePermission.WebApp/Controllers/LoginController.cs
(开头部分) 8KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using RolePermission.Common;
using RolePermission.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNetCore.Mvc;
using RolePermission.BLL;
namespace RolePermission.WebApp.Controllers
{
public class LoginController : BaseController
{
private readonly SMUSERTBService SMUSERTBService;
public LoginController(SMUSERTBService userService)
{
SMUSERTBService = userService;
}
/// <summary>
/// 登录界面
/// </summary>
/// <returns></returns>
public ActionResult Index()
{
CheckCookieInfo();
return View();
}
/// <summary>
/// 点击登录系统
/// </summary>
/// <param name="model">登录信息</param>
/// <returns></returns>
[HttpPost]
[ValidateAntiForgeryToken]//防伪造令牌来避免CSRF攻击
public ActionResult Index(LogOnModel model)
{
#region 验证码验证
if (GetSession("ValidateCode") != null && model.ValidateCode != null && model.ValidateCode.ToLower() != GetSession("ValidateCode").ToString())
{
ModelState.AddModelError("Error_PersonLogin", "验证码错误!");
return View();
}
SetSession("ValidateCode", null);
#endregion
if (ModelState.IsValid)
{
var op = Encrypt.DecodeText(model.Password);
SMUSERTB person = SMUSERTBService.ValidateUser(model.PersonName, Encrypt.DecodeText(model.Password));
if (person != null) //登录成功
{
Account account = person.ToAccount();
string sessionId = Guid.NewGuid().ToString();//作为Memcache的key
try
{
MemcacheHelper.Set(sessionId, Common.SerializerHelper.SerializeToString(account), DateTime.Now.AddMinutes(20));//使用Memcache代替Session解决数据在不同Web服务器之间共享的问题。
}
后面还有 126 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。