Ejemplo n.º 1
0
        public static IKickPrincipal GetPrincipal(string username, string password)
        {
            System.Diagnostics.Trace.WriteLine("GetPrincipal " + username + " : " + password);
            string    securityToken = UserBR.AuthenticateUser(username, password);
            IIdentity identity      = new ApiIdentity(username);

            return(new AuthenticatedKickPrincipal(identity, UserCache.GetUser(securityToken)));
        }
Ejemplo n.º 2
0
        protected void ChangePassword_Click(object sender, EventArgs e)
        {
            if (this.RequiresOldPassword)
            {
                //check if the old password matches
                try {
                    UserBR.AuthenticateUser(this.KickPage.KickUserProfile.Username, OldPassword.Text);
                } catch {
                    InvalidPassword.Visible = true;
                }
            }

            //update the password for the current user
            UserBR.UpdatePassword(this.KickPage.KickUserProfile.UserID, NewPassword.Text, this.KickPage.HostProfile);

            this.SuccessPanel.Visible        = true;
            this.ChangePasswordPanel.Visible = false;
        }
Ejemplo n.º 3
0
        public static bool Login(string username, string password, bool isPersistant)
        {
            string securityToken;

            try {
                securityToken = UserBR.AuthenticateUser(username, password);
            } catch (SecurityException) {
                return(false);
            }

            DateTime expiryDate = DateTime.Now;

            if (isPersistant)
            {
                expiryDate = expiryDate.AddYears(1);
            }
            else
            {
                expiryDate = expiryDate.AddDays(1);
            }

            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                1, username, DateTime.Now, expiryDate, isPersistant,
                securityToken, FormsAuthentication.FormsCookiePath);

            string     encryptedTicket = FormsAuthentication.Encrypt(ticket);
            HttpCookie cookie          = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

            if (isPersistant)
            {
                cookie.Expires = expiryDate;
            }

            HttpContext.Current.Response.Cookies.Add(cookie);

            return(true);
        }