private static TmsAuthenticationRequest GetCredentials() { Log.Debug("Getting credentials"); var config = new Configuration().Tms; var output = new TmsAuthenticationRequest(config.Username, config.Password); return(output); }
private void SignIn(TmsAuthenticationRequest body) { Log.Debug("Signing in"); ClearSession(); var request = new RestRequest("/tmsapi/authenticate"); request.AddJsonBody(body); var response = Client.Post <ResponseBase <AuthenticationDataResponse> >(request); if (!response.IsSuccessful) { Log.Error(response.Content); throw new AuthenticationException(response.Data.Message); } AuthData = response.Data.Data; CookieUtils.ParseCookies(response, Client.CookieContainer, Client.BaseUrl); SaveSession(); IsAuthenticated = true; Log.Debug("Signed In"); }
void ExecuteLoginCommand() { try { var username = Username; var password = Password.GetString(); var request = new TmsAuthenticationRequest(username, password); var parameters = new DialogParameters { { "Username", username }, { "Password", password }, { "RememberPassword", IsRememberPassword }, }; RequestClose?.Invoke(new DialogResult(ButtonResult.OK, parameters)); } catch (Exception ex) { Log.Error(ex, "Failed to login"); MessageBox.Show(ex.Message, "Failed to login", MessageBoxButton.OK, MessageBoxImage.Error); } }