code/Athena0.0.1/SSO.Web/LoginIn.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Athena.basedal;
using Athena.dal;
using Athena.bll;
using Athena.common.Cache.Factory;
using System.Web;
using System.Web.Mvc;

namespace SSO.Web
{
    public class LoginIn:Controller
    {
        protected AccountsPrincipal acctx = null;//当前用户上下文对象
        
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                DB.GetInstance();
                Athena.basedal.IocModule i = new IocModule();
                context.Response.ContentType = "text/plain";
                if (context.Request["action"] == "login")
                {
                    string userName = context.Request["username"];
                    string password = context.Request["password"];
                    acctx = AccountsPrincipal.ValidateLogin(userName, password);
                    if (acctx != null)
                    {
                        string userLoginId = Guid.NewGuid().ToString();
                        CacheFactory.Cache().WriteCache<AccountsPrincipal>(acctx, userLoginId, DateTime.Now.AddMinutes(20));
                        HttpCookie userLoginInCookie = new HttpCookie("userLoginId");
                        //
                        userLoginInCookie.Value = userLoginId;
                        context.User = acctx; System.Web.HttpContext.Current.Response.Cookies.Add(userLoginInCookie);
                        context.Response.Write("true");
                    }
                }
            }
            catch (Exception e)
            {
                context.Response.Write(e.ToString());
            }
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

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

AI 解读

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

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