-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
41 lines (34 loc) · 1.15 KB
/
index.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
---
layout: default
---
<div class="container">
<div class="jumbotron text-center">
<i class="logo-huge">_</i>
<h1>Gitblog</h1>
<p>Easiest way to post on Github Pages.</p><br><br><br>
<p><a id="oauth" class="btn btn-primary btn-lg" role="button"><i class="icon-github-alt"></i> Login with Github</a></p>
</div>
</div>
<script>
(function(window){
window.document.getElementById('oauth').addEventListener('click', oauthHandler);
loginRedirect();
function oauthHandler(){
var state = Math.floor((new Date()).getTime()*Math.random()).toString()
sessionStorage.setItem('state', state)
window.location.href = "https://github.com/login/oauth/authorize?client_id=e01393d04d6b30f08267&scope=public_repo,read:org&state=" + state
}
// check localStorage in the homepage
function loginRedirect()
{
var tokenReg = /\w{40}/,
tokenItem = localStorage.getItem('token');
if(tokenItem != null && tokenItem.match(tokenReg)){
// if yes, redirect to /app/#!/
window.location.href="/app/";
}else{
// do nothing
}
}
})(window);
</script>