🚸 imporve redirect page

This commit is contained in:
naiba 2022-04-30 21:39:25 +08:00
parent 3a873f34d3
commit c2625240c4
2 changed files with 5 additions and 4 deletions

View File

@ -64,9 +64,9 @@ func (oa *oauth2controller) login(c *gin.Context) {
singleton.Cache.Set(fmt.Sprintf("%s%s", model.CacheKeyOauth2State, stateKey), state, cache.DefaultExpiration) singleton.Cache.Set(fmt.Sprintf("%s%s", model.CacheKeyOauth2State, stateKey), state, cache.DefaultExpiration)
url := oa.getCommonOauth2Config(c).AuthCodeURL(state, oauth2.AccessTypeOnline) url := oa.getCommonOauth2Config(c).AuthCodeURL(state, oauth2.AccessTypeOnline)
c.SetCookie(singleton.Conf.Site.CookieName+"-sk", stateKey, 60*5, "", "", false, false) c.SetCookie(singleton.Conf.Site.CookieName+"-sk", stateKey, 60*5, "", "", false, false)
c.HTML(http.StatusOK, "dashboard/redirect", gin.H{ c.HTML(http.StatusOK, "dashboard/redirect", mygin.CommonEnvironment(c, gin.H{
"URL": url, "URL": url,
}) }))
} }
func (oa *oauth2controller) callback(c *gin.Context) { func (oa *oauth2controller) callback(c *gin.Context) {
@ -125,7 +125,7 @@ func (oa *oauth2controller) callback(c *gin.Context) {
user.IssueNewToken() user.IssueNewToken()
singleton.DB.Save(&user) singleton.DB.Save(&user)
c.SetCookie(singleton.Conf.Site.CookieName, user.Token, 60*60*24, "", "", false, false) c.SetCookie(singleton.Conf.Site.CookieName, user.Token, 60*60*24, "", "", false, false)
c.HTML(http.StatusOK, "dashboard/redirect", gin.H{ c.HTML(http.StatusOK, "dashboard/redirect", mygin.CommonEnvironment(c, gin.H{
"URL": "/", "URL": "/",
}) }))
} }

View File

@ -10,6 +10,7 @@
</head> </head>
<body> <body>
<p>Please click <a href="{{.URL}}">here</a> if you are not redirected.</p>
<script>window.location.href = "{{.URL}}"</script> <script>window.location.href = "{{.URL}}"</script>
</body> </body>