public override bool UpdateMembershipUser(HiMembershipUser user) { bool result; if (user == null) { result = false; } else { try { HiMembership.Update(user.Membership); } catch { result = false; return(result); } System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_Users SET MobilePIN = @MobilePIN, Gender = @Gender, BirthDate = @BirthDate WHERE UserId = @UserId"); this.database.AddInParameter(sqlStringCommand, "MobilePIN", System.Data.DbType.String, user.MobilePIN); this.database.AddInParameter(sqlStringCommand, "Gender", System.Data.DbType.Int32, (int)user.Gender); this.database.AddInParameter(sqlStringCommand, "BirthDate", System.Data.DbType.DateTime, user.BirthDate); this.database.AddInParameter(sqlStringCommand, "UserId", System.Data.DbType.Int32, user.UserId); result = (this.database.ExecuteNonQuery(sqlStringCommand) == 1); } return(result); }
public static CreateUserStatus CreateOnlyDistributorUser(IUser user, string roles) { CreateUserStatus unknownFailure = UserHelper.CreateOnlyDistributor(user.MembershipUser, new string[] { roles }); if ((unknownFailure == CreateUserStatus.Created) && !DistributorFactory.Instance().Create(user)) { HiMembership.Delete(user.Username); unknownFailure = CreateUserStatus.UnknownFailure; } return(unknownFailure); }
public static CreateUserStatus CreateUser(IUser user, string[] roles) { CreateUserStatus unknownFailure = UserHelper.Create(user.MembershipUser, roles); if ((unknownFailure == CreateUserStatus.Created) && !UserFactory.Create(user.UserRole).Create(user)) { HiMembership.Delete(user.Username); unknownFailure = CreateUserStatus.UnknownFailure; } return(unknownFailure); }
public static CreateUserStatus CreateUser(IUser user, string[] roles) { CreateUserStatus createUserStatus = UserHelper.Create(user.MembershipUser, roles); if (createUserStatus == CreateUserStatus.Created && !Class0.smethod_0(user.UserRole).vmethod_2(user)) { HiMembership.Delete(user.Username); createUserStatus = CreateUserStatus.UnknownFailure; } return(createUserStatus); }
public override HiMembershipUser GetMembershipUser(int userId, string username, bool isOnline) { MembershipUser mu = string.IsNullOrEmpty(username) ? HiMembership.GetUser(userId, isOnline) : HiMembership.GetUser(username, isOnline); if (mu == null) { return(null); } HiMembershipUser user2 = null; DbCommand sqlStringCommand = null; if (!string.IsNullOrEmpty(username)) { sqlStringCommand = this.database.GetSqlStringCommand( "SELECT MobileAlias, IsAnonymous FROM aspnet_Users WHERE LoweredUserName = LOWER(@Username)"); this.database.AddInParameter(sqlStringCommand, "Username", DbType.String, username); } else { sqlStringCommand = this.database.GetSqlStringCommand( "SELECT MobilePIN, IsAnonymous, Gender, BirthDate, UserRole FROM aspnet_Users WHERE UserId = @UserId"); this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, userId); } using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { if (reader.Read()) { user2 = new HiMembershipUser((bool)reader["IsAnonymous"], UserRole.SiteManager, mu); if (reader["MobilePIN"] != DBNull.Value) { user2.MobilePIN = (string)reader["MobilePIN"]; } if (reader["Gender"] != DBNull.Value) { user2.Gender = (Gender)Convert.ToInt32(reader["Gender"]); } if (reader["BirthDate"] != DBNull.Value) { user2.BirthDate = new DateTime?((DateTime)reader["BirthDate"]); } } reader.Close(); } return(user2); }
public static CreateUserStatus CreateUser(IUser user, string[] roles) { CreateUserStatus createUserStatus = UserHelper.Create(user.MembershipUser, roles); if (createUserStatus == CreateUserStatus.Created) { UserFactory userFactory = UserFactory.Create(user.UserRole); if (!userFactory.Create(user)) { HiMembership.Delete(user.Username); createUserStatus = CreateUserStatus.UnknownFailure; } } return(createUserStatus); }
public override HiMembershipUser GetMembershipUser(int userId, string username, bool isOnline) { MembershipUser membershipUser = string.IsNullOrEmpty(username) ? HiMembership.GetUser(userId, isOnline) : HiMembership.GetUser(username, isOnline); HiMembershipUser result; if (membershipUser == null) { result = null; } else { HiMembershipUser hiMembershipUser = null; System.Data.Common.DbCommand sqlStringCommand; if (!string.IsNullOrEmpty(username)) { sqlStringCommand = this.database.GetSqlStringCommand("SELECT MobilePIN, IsAnonymous, Gender, BirthDate, UserRole FROM aspnet_Users WHERE LoweredUserName = LOWER(@Username)"); this.database.AddInParameter(sqlStringCommand, "Username", System.Data.DbType.String, username); } else { sqlStringCommand = this.database.GetSqlStringCommand("SELECT MobilePIN, IsAnonymous, Gender, BirthDate, UserRole FROM aspnet_Users WHERE UserId = @UserId"); this.database.AddInParameter(sqlStringCommand, "UserId", System.Data.DbType.Int32, userId); } using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { if (dataReader.Read()) { hiMembershipUser = new HiMembershipUser((bool)dataReader["IsAnonymous"], (UserRole)Convert.ToInt32(dataReader["UserRole"]), membershipUser); if (dataReader["MobilePIN"] != DBNull.Value) { hiMembershipUser.MobilePIN = (string)dataReader["MobilePIN"]; } if (dataReader["Gender"] != DBNull.Value) { hiMembershipUser.Gender = (Gender)Convert.ToInt32(dataReader["Gender"]); } if (dataReader["BirthDate"] != DBNull.Value) { hiMembershipUser.BirthDate = new DateTime?((DateTime)dataReader["BirthDate"]); } } dataReader.Close(); } result = hiMembershipUser; } return(result); }
public override CreateUserStatus CreateMembershipUser(HiMembershipUser userToCreate, string passwordQuestion, string passwordAnswer) { CreateUserStatus unknownFailure = CreateUserStatus.UnknownFailure; if (userToCreate == null) { return(CreateUserStatus.UnknownFailure); } bool flag = false; if (!string.IsNullOrEmpty(passwordQuestion) && !string.IsNullOrEmpty(passwordAnswer)) { flag = true; if ((passwordAnswer.Length > 0x80) || (passwordQuestion.Length > 0x100)) { throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer); } } MembershipUser user = HiMembership.Create(userToCreate.Username, userToCreate.Password, userToCreate.Email); if (user != null) { userToCreate.UserId = (int)user.ProviderUserKey; DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_Users SET IsAnonymous = @IsAnonymous, IsApproved = @IsApproved, PasswordQuestion = @PasswordQuestion, PasswordAnswer = @PasswordAnswer, Gender = @Gender, BirthDate = @BirthDate, UserRole = @UserRole WHERE UserId = @UserId"); this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, userToCreate.UserId); this.database.AddInParameter(sqlStringCommand, "IsAnonymous", DbType.Boolean, userToCreate.IsAnonymous); this.database.AddInParameter(sqlStringCommand, "IsApproved", DbType.Boolean, userToCreate.IsApproved); this.database.AddInParameter(sqlStringCommand, "Gender", DbType.Int32, (int)userToCreate.Gender); this.database.AddInParameter(sqlStringCommand, "BirthDate", DbType.DateTime, null); this.database.AddInParameter(sqlStringCommand, "UserRole", DbType.Int32, (int)userToCreate.UserRole); this.database.AddInParameter(sqlStringCommand, "PasswordQuestion", DbType.String, null); this.database.AddInParameter(sqlStringCommand, "PasswordAnswer", DbType.String, null); if (userToCreate.BirthDate.HasValue) { this.database.SetParameterValue(sqlStringCommand, "BirthDate", userToCreate.BirthDate.Value); } if (flag) { string str2 = null; try { int num; int num2; string str; this.GetPasswordWithFormat(userToCreate.Username, false, out num2, out num, out str); if (num2 == 0) { str2 = UserHelper.EncodePassword((MembershipPasswordFormat)num, passwordAnswer, str); this.database.SetParameterValue(sqlStringCommand, "PasswordQuestion", passwordQuestion); this.database.SetParameterValue(sqlStringCommand, "PasswordAnswer", str2); } if ((num2 != 0) || (!string.IsNullOrEmpty(str2) && (str2.Length > 0x80))) { HiMembership.Delete(userToCreate.Username); throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer); } } catch { HiMembership.Delete(userToCreate.Username); throw new CreateUserException(CreateUserStatus.UnknownFailure); } } if (this.database.ExecuteNonQuery(sqlStringCommand) == 1) { unknownFailure = CreateUserStatus.Created; } else { HiMembership.Delete(userToCreate.Username); throw new CreateUserException(unknownFailure); } } return(unknownFailure); }
public override CreateUserStatus CreateMembershipUser(HiMembershipUser userToCreate, string passwordQuestion, string passwordAnswer) { CreateUserStatus createUserStatus = CreateUserStatus.UnknownFailure; CreateUserStatus result; if (userToCreate == null) { result = CreateUserStatus.UnknownFailure; } else { bool flag = false; if (!string.IsNullOrEmpty(passwordQuestion) && !string.IsNullOrEmpty(passwordAnswer)) { flag = true; if (passwordAnswer.Length > 128 || passwordQuestion.Length > 256) { throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer); } } MembershipUser membershipUser = HiMembership.Create(userToCreate.Username, userToCreate.Password, userToCreate.Email); if (membershipUser != null) { userToCreate.UserId = (int)membershipUser.ProviderUserKey; System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_Users SET IsAnonymous = @IsAnonymous, IsApproved = @IsApproved, PasswordQuestion = @PasswordQuestion, PasswordAnswer = @PasswordAnswer, Gender = @Gender, BirthDate = @BirthDate, UserRole = @UserRole WHERE UserId = @UserId"); this.database.AddInParameter(sqlStringCommand, "UserId", System.Data.DbType.Int32, userToCreate.UserId); this.database.AddInParameter(sqlStringCommand, "IsAnonymous", System.Data.DbType.Boolean, userToCreate.IsAnonymous); this.database.AddInParameter(sqlStringCommand, "IsApproved", System.Data.DbType.Boolean, userToCreate.IsApproved); this.database.AddInParameter(sqlStringCommand, "Gender", System.Data.DbType.Int32, (int)userToCreate.Gender); this.database.AddInParameter(sqlStringCommand, "BirthDate", System.Data.DbType.DateTime, null); this.database.AddInParameter(sqlStringCommand, "UserRole", System.Data.DbType.Int32, (int)userToCreate.UserRole); this.database.AddInParameter(sqlStringCommand, "PasswordQuestion", System.Data.DbType.String, null); this.database.AddInParameter(sqlStringCommand, "PasswordAnswer", System.Data.DbType.String, null); if (userToCreate.BirthDate.HasValue) { this.database.SetParameterValue(sqlStringCommand, "BirthDate", userToCreate.BirthDate.Value); } if (flag) { string text = null; try { int num; int format; string salt; this.GetPasswordWithFormat(userToCreate.Username, false, out num, out format, out salt); if (num == 0) { text = UserHelper.EncodePassword((MembershipPasswordFormat)format, passwordAnswer, salt); this.database.SetParameterValue(sqlStringCommand, "PasswordQuestion", passwordQuestion); this.database.SetParameterValue(sqlStringCommand, "PasswordAnswer", text); } if (num != 0 || (!string.IsNullOrEmpty(text) && text.Length > 128)) { HiMembership.Delete(userToCreate.Username); throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer); } } catch { HiMembership.Delete(userToCreate.Username); throw new CreateUserException(CreateUserStatus.UnknownFailure); } } if (this.database.ExecuteNonQuery(sqlStringCommand) != 1) { HiMembership.Delete(userToCreate.Username); throw new CreateUserException(createUserStatus); } createUserStatus = CreateUserStatus.Created; } result = createUserStatus; } return(result); }