public IUserAuth GetUserAuthByUserName(string userNameOrEmail) { CloudTable userTable = _tableRepository.GetTable(Tables.Users); TableQuery <UserEntry> userQuery = userTable.CreateQuery <UserEntry>(); var username = userNameOrEmail; var email = userNameOrEmail; username = TableEntityHelper.RemoveDiacritics(username); username = TableEntityHelper.ToAzureKeyString(username); var result = (from k in userQuery where k.RowKey == username || k.Email == email select k).ToArray(); return(result.FirstOrDefault()); }
public IUserAuth CreateUserAuth(IUserAuth newUser, string password) { UserEntry user = newUser as UserEntry; ValidateNewUser(user, password); AssertNoExistingUser(user); var saltedHash = HostContext.Resolve <IHashProvider>(); string salt; string hash; saltedHash.GetHashAndSaltString(password, out hash, out salt); user.PartitionKey = Guid.NewGuid().ToString(); user.RowKey = newUser.UserName; user.RowKey = TableEntityHelper.RemoveDiacritics(user.RowKey); user.RowKey = TableEntityHelper.ToAzureKeyString(user.RowKey); //user.Id = 0; user.PasswordHash = hash; user.Salt = salt; var digestHelper = new DigestAuthFunctions(); user.DigestHa1Hash = digestHelper.CreateHa1(user.UserName, DigestAuthProvider.Realm, password); user.CreatedDate = DateTime.UtcNow; user.ModifiedDate = user.CreatedDate; //var userId = user.Id.ToString(CultureInfo.InvariantCulture); //if (!newUser.UserName.IsNullOrEmpty()) //{ // redis.SetEntryInHash(IndexUserNameToUserId, newUser.UserName, userId); //} //if (!newUser.Email.IsNullOrEmpty()) //{ // redis.SetEntryInHash(IndexEmailToUserId, newUser.Email, userId); //} SaveUserAuth(user); return(user); }