MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / discourseRedirect

Method discourseRedirect

internal/panel/handler.go:464–491  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

462}
463
464func (h *Handler) discourseRedirect(w http.ResponseWriter, r *http.Request) {
465 if !h.discourse.Enabled() {
466 http.Redirect(w, r, "/login", http.StatusFound)
467 return
468 }
469 if r.URL.Query().Get("spa") == "1" {
470 http.SetCookie(w, &http.Cookie{
471 Name: "discourse_spa",
472 Value: "1",
473 Path: "/",
474 MaxAge: 300,
475 HttpOnly: true,
476 Secure: true,
477 SameSite: http.SameSiteLaxMode,
478 })
479 }
480 scheme := "https"
481 if r.TLS == nil {
482 scheme = "http"
483 }
484 returnURL := fmt.Sprintf("%s://%s/auth/discourse/callback", scheme, r.Host)
485 redirectURL, err := h.discourse.BuildRedirectURL(returnURL)
486 if err != nil {
487 http.Error(w, "SSO 初始化失败", http.StatusInternalServerError)
488 return
489 }
490 http.Redirect(w, r, redirectURL, http.StatusFound)
491}
492
493func (h *Handler) discourseCallback(w http.ResponseWriter, r *http.Request) {
494 if !h.discourse.Enabled() {

Callers

nothing calls this directly

Calls 5

EnabledMethod · 0.80
BuildRedirectURLMethod · 0.80
GetMethod · 0.65
QueryMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected