Formats session response similar to what is returned by CouchDB
(user auth.User, oneTimeSessionID string)
| 332 | |
| 333 | // Formats session response similar to what is returned by CouchDB |
| 334 | func (h *handler) formatSessionResponse(user auth.User, oneTimeSessionID string) db.Body { |
| 335 | |
| 336 | var name *string |
| 337 | allChannels := channels.TimedSet{} |
| 338 | |
| 339 | if user != nil { |
| 340 | userName := user.Name() |
| 341 | if userName != "" { |
| 342 | name = &userName |
| 343 | } |
| 344 | allChannels = user.Channels() |
| 345 | } |
| 346 | |
| 347 | // Return a JSON struct similar to what CouchDB returns: |
| 348 | userCtx := db.Body{"name": name, "channels": allChannels} |
| 349 | handlers := []string{"default", "cookie"} |
| 350 | response := db.Body{"ok": true, "userCtx": userCtx, "authentication_handlers": handlers} |
| 351 | if oneTimeSessionID != "" { |
| 352 | response["one_time_session_id"] = oneTimeSessionID |
| 353 | } |
| 354 | return response |
| 355 | |
| 356 | } |
| 357 | |
| 358 | // checkLoginCORS validates the auth.CORSConfig.LoginOrigin section of CORS for requests. |
| 359 | // Note: Validation of the general Origin header against auth.CORSConfig.Origin happens separately in validateAndWriteHeaders. |
no test coverage detected