public async Task UserRegistrationSucessfully() { var allUsers = repository.Users; foreach (var user in allUsers) { repository.Users.Remove(user); } repository.SaveChanges(); var credentials = new RegisterRequest { Email = "*****@*****.**", Password = "******" }; var content = new StringContent(credentials.ToString(), Encoding.UTF8, "application/json"); var registerResponse = await httpClient.PostAsync("api/auth/login", content); var registerResponseContent = await registerResponse.Content.ReadAsStringAsync(); var registerResult = JsonSerializer.Deserialize <RegisterResponse>(registerResponseContent); Assert.Equal(HttpStatusCode.OK, registerResponse.StatusCode); }
public override Task <RegisterResponse> registerAsSlave(RegisterRequest request, ServerCallContext context) { Console.WriteLine("Received Slave Registration Request: " + request.ToString()); var partitionId = request.PartitionId; var slaveServerId = request.ServerId; var slaveServerUrl = request.Url; _storage.RegisterPartitionSlave(partitionId, slaveServerId, slaveServerUrl); return(Task.FromResult(new RegisterResponse { Ack = true })); }
public async Task <LoginResponse> RegisterUser(RegisterRequest registerModel) { _logger.LogDebug(registerModel.ToString()); var salty = PasswordHasher.GenerateSalt(); var hashedPass = PasswordHasher.HashPass(registerModel.Password, salty); var newUser = new AppUser(); newUser.FirstName = registerModel.FirstName.Trim().ToLower(); newUser.LastName = registerModel.LastName.Trim().ToLower(); newUser.Birthday = registerModel.Birthday; newUser.IsPrivate = false; newUser.IsActive = true; newUser.UserSlug = Guid.NewGuid(); newUser.ActivationKey = new Random().Next(40000, 999999); newUser.Country = registerModel.Country; newUser.Birthday = registerModel.Birthday; newUser.Sex = registerModel.Sex; newUser.Email = registerModel.Email; newUser.Salt = salty; newUser.Password = hashedPass; newUser.UsersToRoles = new List <UsersToRoles> { new UsersToRoles { AppUser = newUser, AppUserRoleId = 3 } }; var response = new LoginResponse(); _context.AppUsers.Add(newUser); await _context.SaveChangesAsync(); return(response); }