如果您创建了一个控制器,如:
public class ProjectLoginController : Controller
{
/// <summary>
/// GET: /login
/// </summary>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public ActionResult Login()
{
return View();
}
}
它将在ProjectLogin
或Shared
文件夹中搜索登录视图。
是否可以告诉MVC此控制器在Account
下的视图文件夹Views
中搜索而不是:
return View("~/Views/Account/Login.cshtml");
或:
return View("../Account/Login");
答案 0 :(得分:1)
您可以使用RedirectToAction()方法。例如,
return RedirectToAction("LogIn", "Account");
或者 - 否则,这样做,
return View("../Account/Login");
锄头有帮助:)
答案 1 :(得分:0)
是的,您可以通过以下方式执行此操作:
public function callback()
{
$user = \Socialite::driver('google')->user();
$idToken = $this->getIdToken($user);
var_dump($idToken);
}
public function getIdToken($user){
$google_client_token = [
'access_token' => $user->token,
'refresh_token' => $user->refreshToken,
'expires_in' => $user->expiresIn
];
$client = new Google_Client();
$client->setAccessToken(json_encode($google_client_token));
$oauth = new Google_Service_Oauth2($client);
$client->authenticate($_GET['code']); //exchange 'code' with access token, refresh token and id token
$accessToken = $client->getAccessToken();
$userData = $oauth->userinfo->get();
return $userData;
}
或
return View("../Account/Login");