/// <summary> /// Sign in using regular user credentials /// </summary> /// <param name="username"> The user's username </param> /// <param name="password"> The user's password </param> /// <param name="signSuccessfull"> An action that will be executed if the sign in was succesfull, contains the server reponse message </param> /// <param name="signInFailed"> An action that will be executed if the sign in was unsuccesfull, contains the server reponse message </param> /// <returns></returns> public async Task <HttpResponseMessage> SignInAsync(string username, SecureString password, Func <HttpResponseMessage, Task> signSuccessfull, Func <HttpResponseMessage, Task> signInFailed) { // Attemp sign in var response = await _serverConnection.LoginAsync(username, password); // If sign in has failed if (response.IsSuccessStatusCode == false) { // Call sign in failed action await signInFailed?.Invoke(response); DI.Logger().Log($"Sign-in failed, Server error response {response.StatusCode}/{(int)response.StatusCode}", LogLevel.Verbose); } // If sign in was succesfull else { await LoginSuccess(response); // Call sign in succeded action await signSuccessfull?.Invoke(response); DI.Logger().Log("Succesfully logged in", LogLevel.Informative); }; return(response); }