WebHostal/war/index.html

78 lines
2.0 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
<h1>Hotel Services.</h1>
Please log in to continue:<br />
<br />
<div class="g-signin2" data-onsuccess="onSignIn"></div>
You can Sign out here:
<a href="#" onclick="signOut();">Sign out</a>
<script>
"use strict";
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
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.
postRedirect("/users/add",{
userEmail : profile.getEmail(),
userName : profile.getName(),
userImg : profile.getImageUrl(),
userRole : "admin",
action : "logIn"
});
}
function postRedirect(url, postData){
var postForm = document.createElement("form");
postForm.action = url;
postForm.method = "POST";
postForm.style.display = "none";
for (var key in postData){
if (postData.hasOwnProperty(key)){
var input = document.createElement("input");
input.type = "hidden";
input.name = key;
input.value = postData[key];
postForm.appendChild(input);
}
}
document.body.appendChild(postForm);
postForm.submit();
}
</script>
<script>
function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('User signed out.');
});
}
</script>
</body>
</html>