🎨 登录跳转
This commit is contained in:
parent
fb124a3a5b
commit
e230dfdb2d
|
@ -55,11 +55,9 @@ func RedirectGitHubHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
clientId := data["clientId"].(string)
|
clientId := data["clientId"].(string)
|
||||||
loginAuthURL := data["loginAuthURL"].(string)
|
loginAuthURL := data["loginAuthURL"].(string)
|
||||||
|
|
||||||
referer := r.URL.Query().Get("referer")
|
state := r.URL.Query().Get("state")
|
||||||
if "" == referer || !strings.Contains(referer, "://") {
|
referer := conf.Wide.Server + "__" + state
|
||||||
referer = conf.Wide.Server + referer
|
state = util.Rand.String(16) + referer
|
||||||
}
|
|
||||||
state := util.Rand.String(16) + referer
|
|
||||||
states[state] = state
|
states[state] = state
|
||||||
path := loginAuthURL + "?client_id=" + clientId + "&state=" + state + "&scope=public_repo,read:user,user:follow"
|
path := loginAuthURL + "?client_id=" + clientId + "&state=" + state + "&scope=public_repo,read:user,user:follow"
|
||||||
http.Redirect(w, r, path, http.StatusSeeOther)
|
http.Redirect(w, r, path, http.StatusSeeOther)
|
||||||
|
|
|
@ -55,8 +55,7 @@
|
||||||
<script type="text/javascript" src="/static/js/lib/jquery-2.1.1.min.js"></script>
|
<script type="text/javascript" src="/static/js/lib/jquery-2.1.1.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$('.oauth').click(function () {
|
$('.oauth').click(function () {
|
||||||
window.location.href = '/oauth/github/redirect?referer=' + document.referrer + '__' +
|
window.location.href = '/oauth/github/redirect?state=' + ($('input').prop('checked') ? '0' : '1')
|
||||||
($('input').prop('checked') ? '0' : '1')
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue