the rest
This commit is contained in:
19
internal/auth/handlers.go
Normal file
19
internal/auth/handlers.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
ory "github.com/ory/client-go"
|
||||
)
|
||||
|
||||
func LogOutHandler(oryClient *ory.APIClient, tunnelURL string) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
cookies := r.Header.Get("Cookie")
|
||||
logoutFlow, _, err := oryClient.FrontendAPI.CreateBrowserLogoutFlow(r.Context()).Cookie(cookies).Execute()
|
||||
if err != nil {
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, logoutFlow.LogoutUrl, http.StatusSeeOther)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user