コード例 #1
0
ファイル: Login.aspx.cs プロジェクト: barnhill/BloodSpider
        private void LoginContainer_Authenticate(object sender, AuthenticateEventArgs e)
        {
            using (GTService.GTServiceClient client = new GTService.GTServiceClient())
            {
                try
                {
                    GTService.Common common = client.ValidateLogin(StringCipher.Encrypt("BloodSpider.Website"), StringCipher.Encrypt("e87c87ba-a48c-4e37-b2c1-9186531afcfb"), StringCipher.Encrypt(StringCipher.Encrypt(this.LoginContainer.UserName, true)), StringCipher.Encrypt(StringCipher.Encrypt(this.LoginContainer.Password, true)));

                    //successful login
                    GTService.Common.sp_GetLoginRow loginRow = common.sp_GetLogin.First();
                    Session.Add("LoggedInUser", loginRow);
                    e.Authenticated = true;

                    //set auth cookie
                    if (LoginContainer.RememberMeSet)
                    {
                        HttpCookie cookie = new HttpCookie(BloodSpider.Services.Common.Statics.AuthenticationCookie);
                        FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, StringCipher.Encrypt(this.LoginContainer.UserName, true), DateTime.Now, DateTime.Now.AddDays(30), true, string.Empty);
                        cookie.Value = FormsAuthentication.Encrypt(authTicket);
                        cookie.Expires = authTicket.Expiration;
                        Response.Cookies.Add(cookie);
                    }
                    else
                    {
                        HttpCookie cookie = new HttpCookie(BloodSpider.Services.Common.Statics.AuthenticationCookie);
                        cookie.Expires = DateTime.Now.AddDays(-1d);
                        Response.Cookies.Add(cookie);
                    }

                    //update last_weblogin datetime
                    client.UpdateLastWebLogin(common);
                }
                catch (Exception ex)
                {
                    //unsuccessful login
                    Session.Clear();
                    FormsAuthentication.SignOut();
                    e.Authenticated = false;
                }
            
            }
        }
コード例 #2
0
ファイル: Login.aspx.cs プロジェクト: springmin/BloodSpider
        private void LoginContainer_Authenticate(object sender, AuthenticateEventArgs e)
        {
            using (GTService.GTServiceClient client = new GTService.GTServiceClient())
            {
                try
                {
                    GTService.Common common = client.ValidateLogin(StringCipher.Encrypt("BloodSpider.Website"), StringCipher.Encrypt("e87c87ba-a48c-4e37-b2c1-9186531afcfb"), StringCipher.Encrypt(StringCipher.Encrypt(this.LoginContainer.UserName, true)), StringCipher.Encrypt(StringCipher.Encrypt(this.LoginContainer.Password, true)));

                    //successful login
                    GTService.Common.sp_GetLoginRow loginRow = common.sp_GetLogin.First();
                    Session.Add("LoggedInUser", loginRow);
                    e.Authenticated = true;

                    //set auth cookie
                    if (LoginContainer.RememberMeSet)
                    {
                        HttpCookie cookie = new HttpCookie(BloodSpider.Services.Common.Statics.AuthenticationCookie);
                        FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, StringCipher.Encrypt(this.LoginContainer.UserName, true), DateTime.Now, DateTime.Now.AddDays(30), true, string.Empty);
                        cookie.Value   = FormsAuthentication.Encrypt(authTicket);
                        cookie.Expires = authTicket.Expiration;
                        Response.Cookies.Add(cookie);
                    }
                    else
                    {
                        HttpCookie cookie = new HttpCookie(BloodSpider.Services.Common.Statics.AuthenticationCookie);
                        cookie.Expires = DateTime.Now.AddDays(-1d);
                        Response.Cookies.Add(cookie);
                    }

                    //update last_weblogin datetime
                    client.UpdateLastWebLogin(common);
                }
                catch (Exception ex)
                {
                    //unsuccessful login
                    Session.Clear();
                    FormsAuthentication.SignOut();
                    e.Authenticated = false;
                }
            }
        }