Beispiel #1
0
 protected void LoginButton_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(UserNameTextBox.Text.Trim()) && !string.IsNullOrEmpty(PasswordTextBox.Text.Trim()))
     {
         using (ResourceDataAccess dataAccess = new ResourceDataAccess())
         {
             //Authenticate User
             AuthenticatedToken authenticatedToken = dataAccess.Authenticate(UserNameTextBox.Text, PasswordTextBox.Text);
             if (authenticatedToken == null)
             {
                 ErrorMessageLabel.Text = Resources.Resources.MsgLoginFailed;
             }
             else
             {
                 Session[Constants.AuthenticationTokenKey] = authenticatedToken;
                 LoginPanel.Visible     = false;
                 LogoutPanel.Visible    = true;
                 LoggedInUserLabel.Text = String.Format(CultureInfo.CurrentCulture, Resources.Resources.MsgWelcomeUser, UserNameTextBox.Text);
                 PasswordTextBox.Text   = string.Empty;
                 if (Request.QueryString[Constants.URL] != null)
                 {
                     Response.Redirect(Request.QueryString[Constants.URL]);
                 }
                 else
                 {
                     Response.Redirect(Request.Url.ToString());
                 }
             }
         }
     }
 }
Beispiel #2
0
    void Application_Start(object sender, EventArgs e)
    {
        //Fired when the first instance of the HttpApplication class is created.
        //It allows you to create objects that are accessible by all
        //HttpApplication instances.

        string guestUserName = UserManager.GuestUserName;
        string guestPassword = Resources.Resources.GuestPassword;

        using (ResourceDataAccess resourceDataAccess = new ResourceDataAccess())
        {
            guestSecurityToken = resourceDataAccess.Authenticate(guestUserName, guestPassword);
        }
    }