@Override
	public ResponseLoginDTO loginUser(String name, String pass) {
		if( name == null || pass == null ){
			throw new IllegalArgumentException("Parameters are null.");
		}
		
		ResponseLoginDTO result = new ResponseLoginDTO(true);
		
		User user = null;
		try {
			if(usersManager.existUser(name) && usersManager.checkPassword(name, pass)){
				user = usersManager.getUser(name);
			}else{
				result.setLoginSuccessful(false);
				result.setMessage("Username or Password incorrect.");
				return result;
			}
		} catch (Exception e) {
//			logger.error("Error in login for user {} : {} ", new Object[]{name,e.getMessage()});
			throw new IllegalStateException("Error in login.");
		}
		
		if (getUserConnected() != null){
			removeAttributeSession();
		}
				
		// User could be connected on other session.
		if(user.isConnect()){
			result.setLoginSuccessful(false);
			result.setMessage("User " + name + "is already logged.");
			return result;
		}
		
		connectOrDisconnect(user, true);
		
		setAttributeSession(convertUserDTO(user));
		
		return result;
	}