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