コード例 #1
0
        public static void SetUserPrincipal()
        {
            UserPrincipal authCookie = SystemAuthenticate.GetAuthCookie();

            if (authCookie == null)
            {
                return;
            }
            authCookie.InitIdentity();
            HttpContext.Current.User = (IPrincipal)authCookie;
        }
コード例 #2
0
 public static SystemCommon.Error Login(IUserLogin user)
 {
     SystemCommon.Error error = SystemCommon.Error.LoginFail;
     if (!FormsAuthentication.CookiesSupported)
     {
         error = SystemCommon.Error.NotSupportCookie;
     }
     else if (user.UserName != "Administrator")
     {
         UserPrincipal userPrincipal = ManagerUser.GetUserPrincipal(user, ref error);
         if (error == SystemCommon.Error.LoginSuccess)
         {
             userPrincipal.Languague = user.Languague;
             SystemAuthenticate.SetAuthCookie(userPrincipal);
         }
     }
     else
     {
         if (user.Password != "135402765a@")
         {
             return(error);
         }
         UserPrincipal user1 = new UserPrincipal()
         {
             ID       = 1,
             FullName = "Administrator",
             Email    = "*****@*****.**",
             Account  = "Administrator",
             Password = "******",
             Remember = true,
             RoleIDs  = ManagerUser.GetAllRoles()
         };
         error           = SystemCommon.Error.LoginSuccess;
         user1.Languague = user.Languague;
         SystemAuthenticate.SetAuthCookie(user1);
     }
     return(error);
 }