Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool isLoggedIn()
- {
- return System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
- }
- public void Login_OnClick(object sender, EventArgs args)
- {
- string email = UserName.Text;
- string password = Password.Text;
- string errorMsg = string.Empty;
- bool cb = cb_agreeterms.Checked;
- if (tests)
- {
- // The code in here tests to see if email, password, etc. have been filled out.
- // This works 100% of the time and is NOT a problem.
- }
- else
- {
- // Validate user.
- if (Membership.ValidateUser(email, password))
- {
- // Get the logged in user
- MembershipUser user = Membership.GetUser(email);
- if (user.IsLockedOut)
- {
- user.UnlockUser();
- }
- // Gets a datatable of the user details in our general database
- DataTable dtUserData = this.dbData.GetUserByEmail(user.UserName);
- if (dtUserData.Rows.Count > 0)
- {
- FormsAuthentication.SetAuthCookie(user.UserName, true);
- // The details for the userId, screenName, etc. below get set by looking at the row 0 in datatable
- // The LoginSession function intializes a session with a guid and saves all the data into an Application Context. This creates a SessionGuid cookie which I see get created on FF and Chrome (and always on IE).
- LoginSession(userId, screenName, permissionLevel, user.UserName);
- Response.Redirect("../myinternalsite.aspx");
- }
- }
- else if (UserExistsInMembership(email))
- {
- // Tested this out and entering bad credentials fails the login and error is shown correctly on screen in the login control.
- // We have failed to login.
- ShowLoginError("E-mail or password is incorrect.");
- }
- }
- }
- public bool isLoggedIn()
- // authenticationConnection works and links correctly to the auth database just fine.
- <sessionState timeout="120"/>
- <membership defaultProvider="SqlProvider">
- <providers>
- <add connectionStringName="authenticationConnection" applicationName="Auth" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" requiresQuestionAndAnswer="false" passwordFormat="Hashed" enablePasswordReset="true" maxInvalidPasswordAttempts="1000" passwordAttemptWindow="1" />
- </providers>
- </membership>
- <roleManager enabled="true" defaultProvider="SqlRoleManager">
- <providers>
- <add name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="authenticationConnection" applicationName="MyApp"/>
- </providers>
- </roleManager>
- <identity impersonate="true"/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement