/// <summary> /// Реализовал здесь, чтобы не тянуть зависимость от окон во ViewModel /// </summary> private void OkButton_Click(object sender, RoutedEventArgs e) { try { var authViewModel = DataContext as AuthWindowViewModel; var codebaseService = CommonContainer.Resolve <ICodebaseService>(authViewModel.CodebaseUrl); codebaseService.LogIn(authViewModel.Username, txtPassword.Password); AuthConfigHelper.LastCodebaseUrl = authViewModel.CodebaseUrl; AuthConfigHelper.LastUsername = authViewModel.Username; if (authViewModel.IsPasswordSaving) { AuthConfigHelper.SavedPassword = txtPassword.Password; } else { AuthConfigHelper.DeletePassword(); } } catch (Exception ex) { MessageBox.Show(ex.Message, this.Title); return; } new MainWindow().Show(); this.Close(); }
public async Task <IActionResult> Post([FromBody] AuthRequestDto authRequestDto) { var user = await GetUserByEmailAndPassword(authRequestDto); if (user == null) { user = await GetUserByRefreshToken(authRequestDto); } if (user == null) { return(StatusCode((int)HttpStatusCode.Forbidden, new AuthResultDto { Authenticated = false, Message = "Authentication failed!" })); } var result = AuthConfigHelper.GenerateToken(user, appSettings, cache, signingConfigurations); return(Response(result)); }