private MembershipUser UserToMembershipUser(User user) { return new MembershipUser(Membership.Provider.Name, user.Username, user.OpenID, user.Email, user.UserID_pk.ToString(), null, true, false, user.CreatedDate, user.LastLoginDate ?? new DateTime(1900, 01, 01), user.LastActivityDate ?? new DateTime(1900, 01, 01), new DateTime(1900, 01, 01), user.LastLockedOutDate ?? new DateTime(1900, 01, 01)); }
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { var args = new ValidatePasswordEventArgs(username, password, true); OnValidatingPassword(args); if (args.Cancel) { status = MembershipCreateStatus.InvalidPassword; return null; } if (RequiresUniqueEmail && GetUserNameByEmail(email) != string.Empty) { status = MembershipCreateStatus.DuplicateEmail; return null; } if (string.IsNullOrEmpty(username)) { status = MembershipCreateStatus.InvalidUserName; return null; } if (string.IsNullOrEmpty(password)) { status = MembershipCreateStatus.InvalidPassword; return null; } if (RequiresUniqueEmail && string.IsNullOrEmpty(email)) { status = MembershipCreateStatus.InvalidEmail; return null; } if (RequiresUniqueEmail && mvcMembershipService.GetUserNameByEmail(email) != string.Empty) { status = MembershipCreateStatus.DuplicateEmail; return null; } var userByOpenID = GetUser(providerUserKey, true); var userByUsername = GetUser(username, false); if (userByOpenID != null || userByUsername != null) { status = MembershipCreateStatus.DuplicateUserName; return null; } var userSalt = mvcMembershipService.CreateSalt(); var hashedPassword = mvcMembershipService.CreatePasswordHash(password, userSalt); var newUser = new User { UserID_pk = Guid.NewGuid(), OpenID = (Guid)providerUserKey, Username = username, Email = email, Password = hashedPassword, PasswordSalt = userSalt, CreatedDate = DateTime.Now, IsActivated = false, IsApproved = false, IsLockedOut = false, LastLockedOutDate = DateTime.Now, LastActivityDate = DateTime.Now, LastLoginDate = DateTime.Now }; mvcMembershipService.AddUser(newUser); status = MembershipCreateStatus.Success; return GetUser(username, true); }
private MembershipUser UserTouched(User user) { mvcMembershipService.UserTouched(user); return UserToMembershipUser(user); }
public void DeleteUser(User user) { throw new NotImplementedException(); }
public User UserTouched(User user) { user.LastActivityDate = DateTime.UtcNow; SaveChanges(); return user; }
public User AddUser(User user) { Add<User>(user); Save<User>(user); return user; }
public void RemoveUser(User user) { Delete<User>(user); }