forked from douglasdrumond/google-calendar-hours
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.html
45 lines (36 loc) · 1.2 KB
/
auth.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Google Calendar Hours Calculator - Authentication</title>
</head>
<body>
<p id="info">
Authentication in process...
</p>
<script type="text/javascript">
function getURLParameter(name, searchOrHash) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(searchOrHash)||[,null])[1]
);
}
var info = document.getElementById("info");
if(getURLParameter("error", location.search) == null) {
info.textContent = "There was a problem with the authentication.";
} else {
var accessToken = getURLParameter("access_token", window.location.hash);
if(accessToken == "null") {
info.textContent = "There was a problem with the authentication.";
} else {
sessionStorage.setItem("auth", JSON.stringify({accessToken:accessToken}));
if(location.href.indexOf("aronwoost.github.io") !== -1) {
window.location = "/google-calendar-hours";
} else {
window.location = "/";
}
}
}
</script>
</body>
</html>