public Optional<User> login(String nameOrEmail, String password) {
		if (nameOrEmail == null || password == null) {
			return Optional.empty();
		}

		User user = userDAO.findByName(nameOrEmail);
		if (user == null) {
			user = userDAO.findByEmail(nameOrEmail);
		}
		if (user != null && !user.isDisabled()) {
			boolean authenticated = encryptionService.authenticate(password, user.getPassword(), user.getSalt());
			if (authenticated) {
				performPostLoginActivities(user);
				return Optional.of(user);
			}
		}
		return Optional.empty();
	}
@Test
	void callingLoginShouldNotReturnUserObjectOnUnsuccessfulAuthentication() {
		Mockito.when(userDAO.findByName("test")).thenReturn(normalUser);
		Mockito.when(passwordEncryptionService.authenticate(Mockito.anyString(), Mockito.any(byte[].class), Mockito.any(byte[].class)))
				.thenReturn(false);

		Optional<User> authenticatedUser = userService.login("test", "password");

		Assertions.assertFalse(authenticatedUser.isPresent());
	}