/// <devdoc> /// Raises the AuthentincatingEvent if atleast one handler is assigned. /// </devdoc> private void OnAuthenticating(AuthenticatingEventArgs e) { EventHandler <AuthenticatingEventArgs> handler = _authenticating; if (null != handler) { handler(this, e); } }
/// <devdoc> /// Validates the user credentials. /// </devdoc> /// <param name="username"></param> /// <param name="password"></param> /// <param name="customCredential"></param> /// <param name="isPersistent"></param> /// <param name="setCookie">If this is true, CreatingCookie event is raised, and cookie is set in HttpResponse</param> /// <returns></returns> private bool LoginInternal(string username, string password, string customCredential, bool isPersistent, bool setCookie) { if (null == username) { throw new ArgumentNullException("username"); } if (null == password) { throw new ArgumentNullException("password"); } AuthenticatingEventArgs authEventArgs = new AuthenticatingEventArgs(username, password, customCredential); try { OnAuthenticating(authEventArgs); if (!authEventArgs.AuthenticationIsComplete) { MembershipValidate(authEventArgs); } if (!authEventArgs.Authenticated) { Logout(); } if (authEventArgs.Authenticated && setCookie) { CreatingCookieEventArgs cookieEventArgs = new CreatingCookieEventArgs(username, password, isPersistent, customCredential); OnCreatingCookie(cookieEventArgs); if (!cookieEventArgs.CookieIsSet) { SetCookie(username, isPersistent); } } } catch (Exception e) { LogException(e); throw; } return(authEventArgs.Authenticated); }
/// <devdoc> /// Raises the AuthentincatingEvent if atleast one handler is assigned. /// </devdoc> private void OnAuthenticating(AuthenticatingEventArgs e) { EventHandler<AuthenticatingEventArgs> handler = _authenticating; if (null != handler) { handler(this, e); } }
private static void MembershipValidate(AuthenticatingEventArgs e) { e.Authenticated = Membership.ValidateUser(e.UserName, e.Password); }
/// <devdoc> /// Validates the user credentials. /// </devdoc> /// <param name="username"></param> /// <param name="password"></param> /// <param name="customCredential"></param> /// <param name="isPersistent"></param> /// <param name="setCookie">If this is true, CreatingCookie event is raised, and cookie is set in HttpResponse</param> /// <returns></returns> private bool LoginInternal(string username, string password, string customCredential, bool isPersistent, bool setCookie) { if (null == username) { throw new ArgumentNullException("username"); } if (null == password) { throw new ArgumentNullException("password"); } AuthenticatingEventArgs authEventArgs = new AuthenticatingEventArgs(username, password, customCredential); try { OnAuthenticating(authEventArgs); if (!authEventArgs.AuthenticationIsComplete) { MembershipValidate(authEventArgs); } if (!authEventArgs.Authenticated) { Logout(); } if (authEventArgs.Authenticated && setCookie) { CreatingCookieEventArgs cookieEventArgs = new CreatingCookieEventArgs(username, password, isPersistent, customCredential); OnCreatingCookie(cookieEventArgs); if (!cookieEventArgs.CookieIsSet) { SetCookie(username, isPersistent); } } } catch (Exception e) { LogException(e); throw; } return authEventArgs.Authenticated; }
public static void Authenticating(object sender, System.Web.ApplicationServices.AuthenticatingEventArgs e) { e.Authenticated = AuthenticationService.authenticate(e.UserName, e.Password); e.AuthenticationIsComplete = true; }
private static void MembershipValidate(AuthenticatingEventArgs e) { e.Authenticated = Membership.ValidateUser(e.UserName, e.Password); }