示例#1
0
        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");
            //}
        }
示例#2
0
        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"));
        }