Add user roles
This commit is contained in:
parent
e72fd6e4d4
commit
cfdd4817e2
6 changed files with 27 additions and 9 deletions
10
admin.go
10
admin.go
|
@ -39,7 +39,7 @@ func settingsHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
|
|||
}
|
||||
|
||||
func deleteHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
|
||||
if sess.User == "" {
|
||||
if !sess.IsAdmin() {
|
||||
notFound(w, r)
|
||||
return
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ func deleteHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
|
|||
|
||||
func editHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
|
||||
idStr := mux.Vars(r)["id"]
|
||||
if sess.User == "" || !bson.IsObjectIdHex(idStr) {
|
||||
if !sess.IsAdmin() || !bson.IsObjectIdHex(idStr) {
|
||||
notFound(w, r)
|
||||
return
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func cleanEmptyStr(s []string) []string {
|
|||
|
||||
func saveHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
|
||||
idStr := mux.Vars(r)["id"]
|
||||
if sess.User == "" || !bson.IsObjectIdHex(idStr) {
|
||||
if !sess.IsAdmin() || !bson.IsObjectIdHex(idStr) {
|
||||
notFound(w, r)
|
||||
return
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ type newData struct {
|
|||
}
|
||||
|
||||
func newHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
|
||||
if sess.User == "" {
|
||||
if !sess.IsAdmin() {
|
||||
notFound(w, r)
|
||||
return
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ func newHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
|
|||
}
|
||||
|
||||
func storeHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
|
||||
if sess.User == "" {
|
||||
if !sess.IsAdmin() {
|
||||
notFound(w, r)
|
||||
return
|
||||
}
|
||||
|
|
Reference in a new issue