Exemple #1
0
        /// <summary>
        /// Sign in using a stored cookie
        /// </summary>
        /// <param name="cookie"> The stored cookie </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> CookieSignInAsync(string cookie, Func <HttpResponseMessage, Task> signSuccessfull, Func <HttpResponseMessage, Task> signInFailed)
        {
            // Get project list
            var response = await _serverConnection.CookieLoginAsync(cookie);


            // 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);
        }