public override MembershipUser GetUser(string username, bool userIsOnline) { MembershipUser u = null; try { Professional_Gift_Card_System.Models.IUserDAO UserRepository = new Professional_Gift_Card_System.Models.UserDAO(); User Ch = UserRepository.GetUser(username); if (Ch != null) { u = GetUserFromDatabaseUser(Ch); if (userIsOnline) { UserRepository.UpdateUserOnline(username); } } } catch (Exception e) { if (WriteExceptionsToEventLog) { WriteToEventLog(e, "GetUser(String, Boolean)"); throw new ProviderException(exceptionMessage); } else { throw e; } } return(u); }
public override string GetUserNameByEmail(string email) { string username = ""; try { Professional_Gift_Card_System.Models.IUserDAO UserRepository = new Professional_Gift_Card_System.Models.UserDAO(); User DBUser = UserRepository.GetUserByEmail(email); if (DBUser != null) { username = (string)DBUser.UserName; } } catch (Exception e) { if (WriteExceptionsToEventLog) { WriteToEventLog(e, "GetUserNameByEmail"); throw new ProviderException(exceptionMessage); } else { throw e; } } if (username == null) { username = ""; } return(username); }
public override bool ValidateUser(string username, string password) { bool isValid = false; try { Professional_Gift_Card_System.Models.IUserDAO UserRepository = new Professional_Gift_Card_System.Models.UserDAO(); isValid = UserRepository.ValidateUser(username, password, PasswordAttemptWindow, MaxInvalidPasswordAttempts); } catch (Exception e) { if (WriteExceptionsToEventLog) { WriteToEventLog(e, "ValidateUser"); throw new ProviderException(exceptionMessage); } else { throw e; } } return(isValid); }
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true); OnValidatingPassword(args); if (args.Cancel) { status = MembershipCreateStatus.InvalidPassword; return(null); } if (RequiresUniqueEmail && GetUserNameByEmail(email) != "") { status = MembershipCreateStatus.DuplicateEmail; return(null); } MembershipUser u = GetUser(username, false); if (u == null) { DateTime createDate = DateTime.Now; if (providerUserKey == null) { providerUserKey = Guid.NewGuid(); } else { if (!(providerUserKey is Guid)) { status = MembershipCreateStatus.InvalidProviderUserKey; return(null); } } User DBUser = new User(); DBUser.PKID = (Guid)providerUserKey; DBUser.ApplicationName = pApplicationName; DBUser.UserName = username; DBUser.Password = Professional_Gift_Card_System.Models.GiftEncryption.EncryptPassword(password); DBUser.Email = email.ToLower(); DBUser.PasswordQuestion = passwordQuestion; DBUser.PasswordAnswer = Professional_Gift_Card_System.Models.GiftEncryption.EncryptPassword(passwordAnswer); DBUser.IsApproved = isApproved; DBUser.Comment = ""; DBUser.CreationDate = createDate; DBUser.LastPasswordChangedDate = createDate; DBUser.LastActivityDate = createDate; DBUser.IsLockedOut = false; DBUser.LastLockedOutDate = createDate; DBUser.FailedPasswordAttemptCount = 0; DBUser.FailedPasswordAnswerAttemptWindowStart = createDate; DBUser.FailedPasswordAnswerAttemptCount = 0; DBUser.FailedPasswordAttemptWindowStart = createDate; try { Professional_Gift_Card_System.Models.IUserDAO UserRepository = new Professional_Gift_Card_System.Models.UserDAO(); if (!UserRepository.CreateUser(DBUser)) { status = MembershipCreateStatus.UserRejected; } else { status = MembershipCreateStatus.Success; } } catch (Exception e) { if (WriteExceptionsToEventLog) { WriteToEventLog(e, "CreateUser"); } status = MembershipCreateStatus.ProviderError; } return(GetUser(username, false)); } else { status = MembershipCreateStatus.DuplicateUserName; } return(null); }