MCPcopy
hub / github.com/usefathom/fathom / GetSession

Method GetSession

pkg/api/auth.go:28–47  ·  view source on GitHub ↗

GET /api/session

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

26
27// GET /api/session
28func (api *API) GetSession(w http.ResponseWriter, r *http.Request) error {
29 userCount, err := api.database.CountUsers()
30 if err != nil {
31 return err
32 }
33
34 // if 0 users in database, dashboard is public
35 if userCount == 0 {
36 return respond(w, http.StatusOK, envelope{Data: true})
37 }
38
39 // if existing session, assume logged-in
40 session, _ := api.sessions.Get(r, "auth")
41 if !session.IsNew {
42 return respond(w, http.StatusOK, envelope{Data: true})
43 }
44
45 // otherwise: not logged-in yet
46 return respond(w, http.StatusOK, envelope{Data: false})
47}
48
49// URL: POST /api/session
50func (api *API) CreateSession(w http.ResponseWriter, r *http.Request) error {

Callers

nothing calls this directly

Calls 2

respondFunction · 0.85
CountUsersMethod · 0.65

Tested by

no test coverage detected