public IActionResult LoginAccount(Login account) { var record = LoginAPI.CheckUserExists(account.Email, _clientBaseAddress.BaseURLApi); if (account == null || record == null) { return(RedirectToAction("LoginView", "Login")); } else { var decryptedPassword = EncryptionAPI.DecryptPassword(record.Password, _clientBaseAddress.BaseURLApi); if (account.Password == decryptedPassword) { return(RedirectToAction("Index", "AdAccounts")); } else { return(BadRequest("Invalid Credentials")); } } //var googleUserData = OAuthAPI.GetGoogleUserData(account.AccessToken, _clientBaseAddress.BaseURLApi); //if (account.Email == googleUserData.email) //{ // return RedirectToAction("Index", "AdAccounts"); //} //else //{ // return BadRequest("Invalid Credentials"); //} }
public IActionResult SaveGoogleAccount(OAuthLogin oauthLogin) { var record = LoginAPI.CheckUserExists(oauthLogin.Email, _clientBaseAddress.BaseURLApi); if (record == null) { var response = OAuthAPI.GenerateToken(_clientBaseAddress.BaseURLApi); oauthLogin.Token = response.access_token; LoginAPI.SaveCredentials(oauthLogin, _clientBaseAddress.BaseURLApi); } return(RedirectToAction("Index", "AdAccounts")); }