/// <summary> /// Create a new user. /// </summary> /// <param name="username">An username of the new user.</param> /// <param name="password">A password of the new user.</param> /// <param name="email">An email address of the new user.</param> /// <param name="firstName">A first name of the new user.</param> /// <param name="lastName">A last name of the new user.</param> /// <param name="isLocked">A value indicating whether the new user account is locked or not.</param> /// <param name="providerUserKey">A user key of the new user, as object.</param> /// <param name="status">A value of type object. Indicate whether the new user is added successfully or not.</param> /// <returns>An object of type "MembershipUser", contains the new user details.</returns> public override MembershipUser CreateUser(string username, string password, string email, string firstName, string lastName, bool isLocked, object providerUserKey, out MembershipCreateStatus status) { ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true); this.OnValidatingPassword(args); if (args.Cancel) { status = MembershipCreateStatus.InvalidPassword; return(null); } if (this.RequiresUniqueEmail && !string.IsNullOrEmpty(this.GetUserNameByEmail(email))) { status = MembershipCreateStatus.DuplicateEmail; return(null); } Account account = new Account(); account.RoleID = AccountProvider.GetRoleID("потребител"); account.Password = AccountProvider.GetMD5Hash(password); account.FirstName = firstName; account.LastName = lastName; account.Email = email; account.CreateDate = DateTime.Now; account.IsLocked = isLocked; AccountProvider.RegisterAccount(account); status = MembershipCreateStatus.Success; return(this.GetUser(email, true)); }
/// <summary> /// Getting an account details based on email address. /// </summary> /// <param name="email">Username as string.</param> /// <param name="userIsOnline">A value indicating whether user must be online at the moment or not.</param> /// <returns>An object of type "MembershipUser", contains user details.</returns> public override MembershipUser GetUser(string email, bool userIsOnline) { Account account = AccountProvider.GetUserObjByEmail(email); if (account != null) { MembershipUser memUAccount = new MembershipUser("CustomMembershipProvider", string.Empty, account.AccountID, account.Email, account.FirstName, account.LastName, true, false, account.CreateDate, DateTime.MinValue, DateTime.MinValue, DateTime.Now, DateTime.Now); return(memUAccount); } return(null); }
public override bool ValidateUser(string loginEmail, string loginPassword) { return(AccountProvider.ValidateAccount(loginEmail, AccountProvider.GetMD5Hash(loginPassword))); }