update auth/logout (#417)
This commit is contained in:
parent
86c0520076
commit
d80ce1d8c5
|
@ -56,3 +56,4 @@ _test
|
||||||
|
|
||||||
tmp/
|
tmp/
|
||||||
main
|
main
|
||||||
|
Makefile
|
||||||
|
|
|
@ -100,28 +100,31 @@ func login(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func logout(c *gin.Context) {
|
func logout(c *gin.Context) {
|
||||||
uuid := readCookieUser(c)
|
func() {
|
||||||
if uuid == "" {
|
uuid := readCookieUser(c)
|
||||||
c.String(200, "logout successfully")
|
if uuid == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
username := models.UsernameByUUID(uuid)
|
||||||
username := models.UsernameByUUID(uuid)
|
if username == "" {
|
||||||
if username == "" {
|
return
|
||||||
c.String(200, "logout successfully")
|
}
|
||||||
return
|
writeCookieUser(c, "")
|
||||||
}
|
go models.LoginLogNew(username, c.ClientIP(), "out")
|
||||||
|
}()
|
||||||
writeCookieUser(c, "")
|
|
||||||
|
|
||||||
if config.Config.SSO.Enable {
|
if config.Config.SSO.Enable {
|
||||||
redirect := queryStr(c, "redirect", "/")
|
redirect := queryStr(c, "redirect", "/")
|
||||||
c.Redirect(302, ssoc.LogoutLocation(redirect))
|
c.Redirect(302, ssoc.LogoutLocation(redirect))
|
||||||
} else {
|
return
|
||||||
c.String(200, "logout successfully")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
go models.LoginLogNew(username, c.ClientIP(), "out")
|
if redirect := queryStr(c, "redirect", ""); redirect != "" {
|
||||||
|
c.Redirect(302, redirect)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.String(200, "logout successfully")
|
||||||
}
|
}
|
||||||
|
|
||||||
type authRedirect struct {
|
type authRedirect struct {
|
||||||
|
@ -131,7 +134,6 @@ type authRedirect struct {
|
||||||
|
|
||||||
func authAuthorizeV2(c *gin.Context) {
|
func authAuthorizeV2(c *gin.Context) {
|
||||||
redirect := queryStr(c, "redirect", "/")
|
redirect := queryStr(c, "redirect", "/")
|
||||||
log.Printf("---> redirect %s", redirect)
|
|
||||||
ret := &authRedirect{Redirect: redirect}
|
ret := &authRedirect{Redirect: redirect}
|
||||||
|
|
||||||
username := cookieUsername(c)
|
username := cookieUsername(c)
|
||||||
|
|
Loading…
Reference in New Issue