feat(api): limit devices credentials access to admin user
This commit is contained in:
parent
73c4457284
commit
2d1a3157f6
|
|
@ -111,6 +111,18 @@ type DeviceAuth struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Api) deviceAuth(w http.ResponseWriter, r *http.Request) {
|
func (a *Api) deviceAuth(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
user, err := a.db.FindUser(r.Context().Value("email").(string))
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
utils.MarshallEncoder(err, w)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if user.Level != AdminUser {
|
||||||
|
w.WriteHeader(http.StatusForbidden)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if r.Method == http.MethodGet {
|
if r.Method == http.MethodGet {
|
||||||
|
|
||||||
id := r.URL.Query().Get("id")
|
id := r.URL.Query().Get("id")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user