(app *App, w http.ResponseWriter, r *http.Request)
| 1438 | } |
| 1439 | |
| 1440 | func handleLogOutCollection(app *App, w http.ResponseWriter, r *http.Request) error { |
| 1441 | alias := collectionAliasFromReq(r) |
| 1442 | var c *Collection |
| 1443 | var err error |
| 1444 | if app.cfg.App.SingleUser { |
| 1445 | c, err = app.db.GetCollectionByID(1) |
| 1446 | } else { |
| 1447 | c, err = app.db.GetCollection(alias) |
| 1448 | } |
| 1449 | if err != nil { |
| 1450 | return err |
| 1451 | } |
| 1452 | if !c.IsProtected() { |
| 1453 | // Invalid to log out of this collection |
| 1454 | return ErrCollectionPageNotFound |
| 1455 | } |
| 1456 | |
| 1457 | err = logOutCollection(app, c.Alias, w, r) |
| 1458 | if err != nil { |
| 1459 | addSessionFlash(app, w, r, "Logging out failed. Try clearing cookies for this site, instead.", nil) |
| 1460 | } |
| 1461 | return impart.HTTPError{http.StatusFound, c.CanonicalURL()} |
| 1462 | } |
nothing calls this directly
no test coverage detected