mirror of
https://github.com/1f349/lavender.git
synced 2024-12-22 07:34:06 +00:00
Add users button to home
This commit is contained in:
parent
c6d64e5d81
commit
ef55d260de
@ -1,6 +1,7 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/1f349/lavender/database"
|
||||||
"github.com/1f349/lavender/pages"
|
"github.com/1f349/lavender/pages"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
@ -16,6 +17,13 @@ func (h *HttpServer) Home(rw http.ResponseWriter, _ *http.Request, _ httprouter.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isAdmin bool
|
||||||
|
h.DbTx(rw, func(tx *database.Tx) (err error) {
|
||||||
|
roles, err := tx.GetUserRoles(auth.Data.ID)
|
||||||
|
isAdmin = HasRole(roles, "lavender:admin")
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
|
||||||
lNonce := uuid.NewString()
|
lNonce := uuid.NewString()
|
||||||
auth.Session.Set("action-nonce", lNonce)
|
auth.Session.Set("action-nonce", lNonce)
|
||||||
if auth.Session.Save() != nil {
|
if auth.Session.Save() != nil {
|
||||||
@ -29,5 +37,6 @@ func (h *HttpServer) Home(rw http.ResponseWriter, _ *http.Request, _ httprouter.
|
|||||||
"Subject": auth.Data.ID,
|
"Subject": auth.Data.ID,
|
||||||
"DisplayName": auth.Data.DisplayName,
|
"DisplayName": auth.Data.DisplayName,
|
||||||
"Nonce": lNonce,
|
"Nonce": lNonce,
|
||||||
|
"IsAdmin": isAdmin,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user