Ejemplo n.º 1
0
 /// <summary>
 /// 尝试使用指定的用户名密码登录,并返回是否成功。
 /// </summary>
 /// <param name="username"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public static bool Login(string username, string password)
 {
     bool IsFlg = false;
     LCLIdentity identity = null;
     if (username == "admin" && password == "123456")
     {
         identity = new LCLIdentity
         {
             User = new User { Name = "admin", Department = new Department { Name = "LCL" } }
         };
         identity.Name = username;
         identity.UserCode = username;
         identity.UnitName = "京通";
         identity.IsAuthenticated = true;
         LEnvironment.Principal = new LCLPrincipal(identity);
         IsFlg= identity.IsAuthenticated;
     }
     else
     {
         identity = RF.Concrete<LCLIdentityRepository>().GetBy(username, password);
         if (identity.IsAuthenticated)
         {
             LEnvironment.Principal = new LCLPrincipal(identity);
         }
         else
         {
             LEnvironment.Principal = new AnonymousPrincipal();
         }
         IsFlg= identity.IsAuthenticated;
     }
     AddCookie(username, LEnvironment.Principal);
     return IsFlg;
 }
Ejemplo n.º 2
0
 internal LCLIdentity GetById(Guid ID)
 {
     var res = new LCLIdentity
     {
         User = RF.Concrete<UserRepository>().GetByKey(ID) as User
     };
     res.LoadChildrenProperties();
     return res;
 }
Ejemplo n.º 3
0
        internal LCLIdentity GetBy(string username, string password)
        {
            var res = new LCLIdentity
            {
                User = RF.Concrete<IUserRepository>().GetBy(username, password)
            };

            res.LoadChildrenProperties();

            return res;
        }
Ejemplo n.º 4
0
 public MyUserDataPrincipal(LCLIdentity realIdentity)
 {
     this._Identity = realIdentity;
 }
Ejemplo n.º 5
0
 private LCLPrincipal(LCLIdentity realIdentity)
 {
     this._userId = realIdentity.UserId;
     this._edsIdentity = realIdentity;
 }