accred/index.php
2019-03-11 15:33:47 +01:00

79 lines
2.1 KiB
PHP

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL & ~E_NOTICE );
// start session
$cfg = include('accred_config.php');
if (session_status() == PHP_SESSION_NONE) {
session_start();
$userid = $_SESSION['uid'];
}
// If we are logged-in, redirect to the list page.
if($userid) {
header("location: accred_list");
die();
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="google-signin-client_id" content="538635499162-g21v86gk87qm863u03er6vnm3q15bl82.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<title>Carbana Accréditations</title>
<link rel="stylesheet" type="text/css" href="accred_style.css">
</head>
<body>
<div id="signin">
<span id="logo">
<img class="loginlogo" src="Caribana_2019_logo_hor.png"/></span>
<h2>Identification</h2><br>
<h2> Saisis ton nom d'utilisateur et mot de passe gmail pour t'identifier et accéder aux demandes d'accréditation en utilisant le bouton ci-dessous.</h2>
<h3>Le mot de passe n'est pas transmis &agrave; Caribana.</h3>
<br>
<br>
<br>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<br>
<br>
</div>
<script>
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
var id_token = googleUser.getAuthResponse().id_token;
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
console.log('Token: ' + id_token);
console.log("Preparing to call tokensignin");
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://accred.caribana-festival.ch/tokensignin');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
console.log('Signed in as: ' + xhr.responseText);
self.location = 'accred_list';
};
xhr.onerror = function() {
console.log("ERROR");
alert("Error");
};
console.log(xhr);
xhr.send('idtoken=' + id_token);
}
</script>
</body>
</html>