From b9e6c5dbe1ab5de3740aed99866dfa1674d95218 Mon Sep 17 00:00:00 2001 From: Andrea Fazzi Date: Mon, 3 Feb 2020 14:13:01 +0100 Subject: [PATCH] Fix ambiguity between user_id and model_id in user token --- VERSION | 2 +- dist/main.bundle.js | 2 +- dist/styles.css | 2 +- handlers/handlers.go | 4 ++-- handlers/login.go | 10 ++++++---- orm/participant.go | 2 +- orm/response.go | 2 +- orm/role.go | 4 ++++ orm/school.go | 4 ++-- orm/usermodifier.go | 4 +++- renderer/funcmap.go | 6 +++--- src/style.css | 2 +- templates/layout/base.html.tpl | 2 +- templates/layout/login.html.tpl | 6 ++---- 14 files changed, 29 insertions(+), 23 deletions(-) diff --git a/VERSION b/VERSION index 2cea6f95..0d7356f4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.1-26-g368de33-master +0.2.1-26-g368de33-master \ No newline at end of file diff --git a/dist/main.bundle.js b/dist/main.bundle.js index a244e352..179246ef 100644 --- a/dist/main.bundle.js +++ b/dist/main.bundle.js @@ -141,4 +141,4 @@ $(function () { /***/ }) /******/ ]); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgZDZjNjM4ZTFkY2EwMzA4MWZmNzMiLCJ3ZWJwYWNrOi8vLy4vc3JjL2luZGV4LmpzIiwid2VicGFjazovLy8uL3NyYy9zdHlsZS5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtRQUFBO1FBQ0E7O1FBRUE7UUFDQTs7UUFFQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTs7UUFFQTtRQUNBOztRQUVBO1FBQ0E7O1FBRUE7UUFDQTtRQUNBOzs7UUFHQTtRQUNBOztRQUVBO1FBQ0E7O1FBRUE7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0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yAuL3NyYy9zdHlsZS5jc3Ncbi8vIG1vZHVsZSBpZCA9IDFcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sInNvdXJjZVJvb3QiOiIifQ== \ No newline at end of file diff --git a/dist/styles.css b/dist/styles.css index 333cbf45..ba4645a6 100644 --- a/dist/styles.css +++ b/dist/styles.css @@ -4,7 +4,7 @@ html { body { padding-top: 60px; - position: relative; + /*position: relative;*/ } div.login { diff --git a/handlers/handlers.go b/handlers/handlers.go index dd25f5cc..44659f56 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -473,7 +473,7 @@ func DefaultHomeHandler() http.Handler { r, fmt.Sprintf( "/participants/%s?format=html&tpl_layout=base&tpl_content=participants_show", - claims["user_id"].(string)), + claims["model_id"].(string)), http.StatusSeeOther, ) @@ -483,7 +483,7 @@ func DefaultHomeHandler() http.Handler { r, fmt.Sprintf( "/schools/%s?format=html&tpl_layout=base&tpl_content=schools_show", - claims["user_id"].(string)), + claims["model_id"].(string)), http.StatusSeeOther, ) diff --git a/handlers/login.go b/handlers/login.go index bf80e488..cfeec108 100644 --- a/handlers/login.go +++ b/handlers/login.go @@ -16,6 +16,7 @@ type UserToken struct { Username string Admin bool Role string + ModelID string UserID string } @@ -68,13 +69,13 @@ func checkCredential(db *orm.Database, username string, password string) (*UserT // Check if user is the administrator if username == db.Config.Admin.Username && password == db.Config.Admin.Password { - return &UserToken{username, true, "administrator", "0"}, nil + return &UserToken{username, true, "administrator", "0", "0"}, nil } // Check if user is a subscriber if password == db.Config.Subscriber.Password { - return &UserToken{"subscriber", false, "subscriber", "0"}, nil + return &UserToken{"subscriber", false, "subscriber", "0", "0"}, nil } var token *UserToken @@ -89,13 +90,13 @@ func checkCredential(db *orm.Database, username string, password string) (*UserT if err := db.DB().First(&participant, &orm.Participant{UserID: user.ID}).Error; err != nil { return nil, errors.New("Authentication failed!") } - token = &UserToken{username, false, user.Role, strconv.Itoa(int(participant.ID))} + token = &UserToken{username, false, user.Role, strconv.Itoa(int(participant.ID)), strconv.Itoa(int(user.ID))} case "school": var school orm.School if err := db.DB().First(&school, &orm.School{UserID: user.ID}).Error; err != nil { return nil, errors.New("Authentication failed!") } - token = &UserToken{username, false, user.Role, strconv.Itoa(int(school.ID))} + token = &UserToken{username, false, user.Role, strconv.Itoa(int(school.ID)), strconv.Itoa(int(user.ID))} } return token, nil @@ -113,6 +114,7 @@ func getToken(db *orm.Database, username string, password string, signingKey []b claims["admin"] = user.Admin claims["username"] = user.Username claims["role"] = user.Role + claims["model_id"] = user.ModelID claims["user_id"] = user.UserID claims["exp"] = time.Now().Add(time.Hour * 24).Unix() diff --git a/orm/participant.go b/orm/participant.go index eda653e0..85b07575 100644 --- a/orm/participant.go +++ b/orm/participant.go @@ -467,7 +467,7 @@ func CreateParticipant(db *Database, participant *Participant) (*Participant, er func SaveParticipant(db *Database, participant interface{}) (interface{}, error) { participant.(*Participant).FiscalCode = strings.ToUpper(participant.(*Participant).FiscalCode) - if err := db._db.Omit("Category", "School").Save(participant).Error; err != nil { + if err := db._db.Omit("Category", "School", "Creator", "Updater").Save(participant).Error; err != nil { return nil, err } return participant, nil diff --git a/orm/response.go b/orm/response.go index dbd5cc36..a5244615 100644 --- a/orm/response.go +++ b/orm/response.go @@ -275,7 +275,7 @@ func CreateResponse(db *Database, response *Response) (*Response, error) { } func SaveResponse(db *Database, response interface{}) (interface{}, error) { - if err := db._db. /*.Omit("Something")*/ Save(response).Error; err != nil { + if err := db._db.Omit("Creator", "Updater").Save(response).Error; err != nil { return nil, err } return response, nil diff --git a/orm/role.go b/orm/role.go index 1b1306ca..ded7ee93 100644 --- a/orm/role.go +++ b/orm/role.go @@ -42,6 +42,10 @@ func getUserIDFromToken(r *http.Request) string { return getClaims(r)["user_id"].(string) } +func getModelIDFromToken(r *http.Request) string { + return getClaims(r)["model_id"].(string) +} + func getUserIDFromTokenAsUint(r *http.Request) uint { id, _ := strconv.Atoi(getUserIDFromToken(r)) return uint(id) diff --git a/orm/school.go b/orm/school.go index d7d5fb56..b40d0ebc 100644 --- a/orm/school.go +++ b/orm/school.go @@ -306,7 +306,7 @@ func CreateSchool(db *Database, school *School) (*School, error) { } func SaveSchool(db *Database, school interface{}) (interface{}, error) { - if err := db._db.Omit("Region").Save(school).Error; err != nil { + if err := db._db.Omit("Region", "Creator", "Updater").Save(school).Error; err != nil { return nil, err } return school, nil @@ -317,7 +317,7 @@ func (model *School) HasCategory(db *Database, participant *Participant) (bool, if err := db._db. Where("category_id = ? AND school_id = ? AND id <> ?", participant.CategoryID, model.ID, participant.ID). - Find(&participants).Error; err != nil { + Find(&participants).Error; err != nil { return false, err } return len(participants) > 0, nil diff --git a/orm/usermodifier.go b/orm/usermodifier.go index c678af32..2af014c3 100644 --- a/orm/usermodifier.go +++ b/orm/usermodifier.go @@ -1,6 +1,8 @@ package orm -import "net/http" +import ( + "net/http" +) type Modifier interface { SetCreatorID(id uint) diff --git a/renderer/funcmap.go b/renderer/funcmap.go index 7b87ded7..aaf6296c 100644 --- a/renderer/funcmap.go +++ b/renderer/funcmap.go @@ -64,7 +64,7 @@ var ( "isSubscriber": isSubscriber, "isSchool": isSchool, "attr": attr, - "userId": userId, + "modelId": modelId, } ) @@ -105,8 +105,8 @@ func username(claims jwt.MapClaims) string { return claims["username"].(string) } -func userId(claims jwt.MapClaims) (uint, error) { - id, err := strconv.Atoi(claims["user_id"].(string)) +func modelId(claims jwt.MapClaims) (uint, error) { + id, err := strconv.Atoi(claims["model_id"].(string)) if err != nil { return 0, err } diff --git a/src/style.css b/src/style.css index d0f10dbf..ed1e3abe 100644 --- a/src/style.css +++ b/src/style.css @@ -4,7 +4,7 @@ html { body { padding-top: 60px; - position: relative; + /*position: relative;*/ } div.login { diff --git a/templates/layout/base.html.tpl b/templates/layout/base.html.tpl index 31c9d95b..077814fe 100644 --- a/templates/layout/base.html.tpl +++ b/templates/layout/base.html.tpl @@ -48,7 +48,7 @@ Prove {{- end -}} {{- if $isSchool -}} - Scuola + Scuola Partecipanti {{- end -}} diff --git a/templates/layout/login.html.tpl b/templates/layout/login.html.tpl index 428a9390..42058533 100644 --- a/templates/layout/login.html.tpl +++ b/templates/layout/login.html.tpl @@ -38,16 +38,14 @@ - -