mirror of
https://github.com/janishutz/oidclogin.git
synced 2026-10-08 17:26:20 +02:00
feat: logout endpoint
This commit is contained in:
1 parent
a9245fd20f
commit
2ae92f8191
3 files changed
+10
No files matched your search
@@ -122,6 +122,14 @@ func callbackHandler(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func logoutHandler(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
session.Clear()
|
||||
session.Save()
|
||||
}
|
||||
|
||||
// Ensure that a user is currently logged in.
|
||||
// If redirectFail is set, then if not, the user is redirected.
|
||||
func EnsureLogin(redirectFail bool) func(c *gin.Context) {
|
||||
return (func(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
|
||||
@@ -62,6 +62,7 @@ func Configure(r *gin.Engine, app_url string, default_redirect string, stubs_on_
|
||||
r.GET("/auth/v2/login", loginHandler)
|
||||
r.GET("/auth/v2/verify", callbackHandler)
|
||||
r.GET("/auth/v2/check", EnsureLogin(false), func(ctx *gin.Context) { ctx.JSON(200, gin.H{"success": "true"}) })
|
||||
r.GET("/auth/v2/logout", logoutHandler)
|
||||
|
||||
log.Println("[JHID] Configured successfully")
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ func startStubs(r *gin.Engine) {
|
||||
r.GET("/auth/v2/login", stubsHandler)
|
||||
r.GET("/auth/v2/verify", stubsHandler)
|
||||
r.GET("/auth/v2/check", EnsureLogin(false), func(ctx *gin.Context) { ctx.JSON(200, gin.H{"success": "true"}) })
|
||||
r.GET("/auth/v2/logout", logoutHandler)
|
||||
}
|
||||
|
||||
func stubsHandler(c *gin.Context) {
|
||||
|
||||
Reference in new issue
Block a user