Exemple #1
0
    public void save_Click(object sender, EventArgs e)
    {
        TransitOpenIdRedirect r = SessionManager.AccountService.GetOpenIdRedirect(inputOpenIdIdentityUrl.Text, Request.Url.ToString());

        SessionManager.OpenIdToken = r.Token;
        Redirect(r.Url);
    }
    protected void CreateOpenId_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(inputName.Text))
        {
            throw new ArgumentException("Please enter your name.");
        }

        if (string.IsNullOrEmpty(inputOpenId.Text))
        {
            throw new ArgumentException("Please enter your open-id.");
        }

        if (string.IsNullOrEmpty(inputEmailAddress.Text))
        {
            throw new ArgumentException("Please enter an e-mail address.");
        }

        if (!inputBirthday.HasDate)
        {
            throw new ArgumentException("Please enter a valid date of birth.");
        }

        // url root needs to be a case-sensitive match for the openid server trust
        TransitOpenIdRedirect redirect = SessionManager.AccountService.GetOpenIdRedirect(inputOpenId.Text, Request.Url.ToString());

        SessionManager.OpenIdToken = redirect.Token;
        Response.Cookies.Add(new HttpCookie("SnCore.AccountCreate.Name", inputName.Text));
        Response.Cookies.Add(new HttpCookie("SnCore.AccountCreate.BetaPassword", inputBetaPassword.Text.Trim()));
        Response.Cookies.Add(new HttpCookie("SnCore.AccountCreate.Email", inputEmailAddress.Text.Trim()));
        Response.Cookies.Add(new HttpCookie("SnCore.AccountCreate.Birthday", inputBirthday.SelectedDate.ToString()));
        Redirect(redirect.Url);
    }
    protected void loginLogin_Click(object sender, EventArgs e)
    {
        try
        {
            string ticket;
            if (!string.IsNullOrEmpty(loginEmailAddress.Text))
            {
                ticket = SessionManager.AccountService.Login(loginEmailAddress.Text, loginPassword.Text.Trim());
                SessionManager.Login(ticket, loginRememberMe.Checked);

                TransitAccount ta = SessionManager.AccountService.GetAccount(ticket, true);
                if (ta != null && ta.IsPasswordExpired)
                {
                    Redirect(string.Format("AccountChangePassword.aspx?ReturnUrl={0}&PasswordHash={1}",
                                           Renderer.UrlEncode(ReturnUrl), Renderer.UrlEncode(ManagedAccount.GetPasswordHash(loginPassword.Text))));
                }
                else
                {
                    Redirect(ReturnUrl);
                }
            }
            else if (!string.IsNullOrEmpty(loginOpenId.Text))
            {
                // url root needs to be a case-sensitive match for the openid server trust
                TransitOpenIdRedirect redirect = SessionManager.AccountService.GetOpenIdRedirect(loginOpenId.Text, Request.Url.ToString());
                SessionManager.OpenIdToken   = redirect.Token;
                SessionManager.RememberLogin = loginRememberMe.Checked;
                Redirect(redirect.Url);
            }
            else
            {
                throw new ManagedAccount.AccessDeniedException();
            }
        }
        catch
        {
            SessionManager.Logout();
            throw;
        }
    }
Exemple #4
0
    public void loginLogin_Click(object sender, EventArgs e)
    {
        try
        {
            string ticket;
            if (!string.IsNullOrEmpty(loginEmailAddress.Text))
            {
                ticket = SessionManager.AccountService.Login(loginEmailAddress.Text.Trim(), loginPassword.Text.Trim());
                SessionManager.Login(ticket, loginRememberMe.Checked);

                TransitAccount ta = SessionManager.AccountService.GetAccount(ticket, true);
                if (ta != null && ta.IsPasswordExpired)
                {
                    throw new Exception("Password expired. You cannot reset it on the mobile site.");
                }
                else
                {
                    Redirect(ReturnUrl);
                }
            }
            else if (!string.IsNullOrEmpty(loginOpenId.Text))
            {
                // url root needs to be a case-sensitive match for the openid server trust
                TransitOpenIdRedirect redirect = SessionManager.AccountService.GetOpenIdRedirect(loginOpenId.Text, Request.Url.ToString());
                SessionManager.OpenIdToken   = redirect.Token;
                SessionManager.RememberLogin = loginRememberMe.Checked;
                Redirect(redirect.Url);
            }
            else
            {
                throw new Exception("Access Denied"); // todo: typed access denied exception
            }
        }
        catch
        {
            SessionManager.Logout();
            throw;
        }
    }