Files
crash-processor/htdocs/process_login.php
Latif Khalifa 5731b4ae24 Switched to Google Oauth2 for login.
Copy init.php.in to init.php

Set database username, password

Set $GoogleClientID and $GoogleClientSecret

To get those:

* Navigate to the Google Cloud Console. https://cloud.google.com/console
* Click on the Create Project button on top of the page, enter the following values and then click on the Create button.
* Once the project has been created, open the APIs & auth group (left navigation pannel) and then click on Consent screen and set it up (this is just for what is shown to the user, values not important)
* Open the APIs & auth group in the left pannel (if it's not already open) and click on Credentials.
* Click on the CREATE NEW CLIENT ID button, enter/tick the following values and then click on the Create Client ID button.

  Application type: Web Application
  Authorized Javascript origins: http://crash.replex.org
  Authorized redirect URI: http://crash.replex.org/process_login.php
  (replace with appropriate links. imporant bit is url to process_login.php)

You will now have Client ID and Client secret
2014-06-05 18:01:33 +02:00

49 lines
896 B
PHP

<?php
define("SITE_ROOT", realpath(dirname(__file__)));
require_once SITE_ROOT . "/lib/init.php";
if (!isset($_GET["code"]) || !GoogleLogin::verifyLogin($_GET["code"]))
{
http::redirect("/login_failed.php");
}
$user_identity = GoogleLogin::userID();
$user_email = GoogleLogin::userEmail();
$user = User::getByLogin($user_identity);
if (!$user)
{
$user = new User();
$user->email = $user_email;
$user->is_admin = 0;
$user->is_allowed = 0;
$user->login = $user_identity;
if (!$user->save())
{
http::redirect("/login_failed.php");
}
}
$S->user = $user;
$S->user_id = $user->user_id;
$S->authenticated = 1;
$S->update();
if (isset($_GET['caller']))
{
http::redirect($_GET['caller']);
}
http::redirect('/');
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/