Hide creator/updater details for non admin
This commit is contained in:
parent
e22d0ce16e
commit
8ceb259ca8
2 changed files with 8 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
package orm
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
|
@ -31,7 +32,7 @@ func NewUserModifierCreate(r *http.Request) *UserModifierCreate {
|
|||
if r.Context().Value("user") != nil {
|
||||
claims = r.Context().Value("user").(*jwt.Token).Claims.(jwt.MapClaims)
|
||||
}
|
||||
println("User id", claims["user_id"])
|
||||
|
||||
return &UserModifierCreate{
|
||||
CreatorID: claims["user_id"].(string),
|
||||
CreatorRole: claims["role"].(string),
|
||||
|
@ -65,6 +66,8 @@ func NewUserModifierUpdate(r *http.Request) *UserModifierUpdate {
|
|||
claims = r.Context().Value("user").(*jwt.Token).Claims.(jwt.MapClaims)
|
||||
}
|
||||
|
||||
log.Println("Claims", claims)
|
||||
|
||||
return &UserModifierUpdate{
|
||||
UpdaterID: claims["user_id"].(string),
|
||||
UpdaterRole: claims["role"].(string),
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
<dd class="col-sm-9">{{.Data.User.Password}}</dd>
|
||||
<dt class="col-sm-3">Categoria</dt>
|
||||
<dd class="col-sm-9">{{.Data.Category}}</dd>
|
||||
|
||||
{{if $isAdmin}}
|
||||
{{if $creatorUser:=.Data.CreatedBy}}
|
||||
<dt class="col-sm-3">Creato da</dt>
|
||||
<dd class="col-sm-9">{{$creatorUser.Username}}[{{$creatorUser.Role}}] {{$.Data.CreatedAt|prettyDateTime}}</dd>
|
||||
|
@ -29,7 +31,8 @@
|
|||
<dt class="col-sm-3">IP di chi ha modificato il partecipante</dt>
|
||||
<dd class="col-sm-9">{{.Data.UpdaterIP}}</dd>
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
</dl>
|
||||
|
||||
<div class="row">
|
||||
|
|
Loading…
Reference in a new issue