mirror of
https://github.com/writefreely/writefreely
synced 2024-11-10 11:24:13 +00:00
Use UserLevelReader func for read routes
Previously, that func was duplicated here.
This commit is contained in:
parent
44a4fd7a79
commit
2b39b714de
1 changed files with 2 additions and 11 deletions
13
routes.go
13
routes.go
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
"github.com/writeas/go-webfinger"
|
||||
"github.com/writeas/web-core/log"
|
||||
"github.com/writeas/writefreely/config"
|
||||
"github.com/writefreely/go-nodeinfo"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
@ -153,16 +152,8 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router {
|
|||
write.HandleFunc("/login", handler.Web(viewLogin, UserLevelNoneRequired))
|
||||
write.HandleFunc("/invite/{code}", handler.Web(handleViewInvite, UserLevelNoneRequired)).Methods("GET")
|
||||
// TODO: show a reader-specific 404 page if the function is disabled
|
||||
readPerm := func(cfg *config.Config) UserLevel {
|
||||
if cfg.App.Private {
|
||||
// Private instance, so only allow users to access Reader routes
|
||||
return UserLevelUserType
|
||||
}
|
||||
return UserLevelOptionalType
|
||||
}
|
||||
|
||||
write.HandleFunc("/read", handler.Web(viewLocalTimeline, readPerm))
|
||||
RouteRead(handler, readPerm, write.PathPrefix("/read").Subrouter())
|
||||
write.HandleFunc("/read", handler.Web(viewLocalTimeline, UserLevelReader))
|
||||
RouteRead(handler, UserLevelReader, write.PathPrefix("/read").Subrouter())
|
||||
|
||||
draftEditPrefix := ""
|
||||
if apper.App().cfg.App.SingleUser {
|
||||
|
|
Loading…
Reference in a new issue