branch bow-v2-go updated (e00acb8 -> 5b2a7d6)
This is an automated email from the git hooks/post-receive script. New change to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git from e00acb8 correction requete de recup du user correction url back (variable) new 5b2a7d6 on ne met plus les actions dans le cookie The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 5b2a7d6aae52de20007023ea56d416a3abe207ee Author: Benjamin <poussin@codelutin.com> Date: Tue May 12 19:06:00 2020 +0200 on ne met plus les actions dans le cookie Summary of changes: pkg/http/opensearchResource.go | 12 ++++++++++++ pkg/http/userResource.go | 3 ++- pkg/repository/userRepository.go | 24 ++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git commit 5b2a7d6aae52de20007023ea56d416a3abe207ee Author: Benjamin <poussin@codelutin.com> Date: Tue May 12 19:06:00 2020 +0200 on ne met plus les actions dans le cookie --- pkg/http/opensearchResource.go | 12 ++++++++++++ pkg/http/userResource.go | 3 ++- pkg/repository/userRepository.go | 24 ++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/pkg/http/opensearchResource.go b/pkg/http/opensearchResource.go index b484784..013be16 100644 --- a/pkg/http/opensearchResource.go +++ b/pkg/http/opensearchResource.go @@ -126,6 +126,18 @@ var actions = map[string]func(w http.ResponseWriter, r *http.Request, currentUse }} func getAction(currentUser model.BowUser, ask string) model.Action { + // les actions ne sont plus dans le cookie (sinon cookie trop gros >4ko) + // donc si on a pas les actions, on les charges (on a les actions si c'est un token qui est utilisé) + actions := currentUser.Actions + if len(actions) == 0 { + tmp, err := repository.User(currentUser, currentUser.ID, "actions") + if err == nil { + actions = tmp.Actions + } else { + log.Println("Can't get action for", currentUser.ID, err) + } + } + var result model.Action for _, a := range currentUser.Actions { prefix := a.Prefix diff --git a/pkg/http/userResource.go b/pkg/http/userResource.go index 50518ad..9c5b75a 100644 --- a/pkg/http/userResource.go +++ b/pkg/http/userResource.go @@ -41,7 +41,8 @@ func createAuth(w http.ResponseWriter, r *http.Request) { log.Println("create token", data["email"], id) pseudoUser := model.BowUser{ID: id} - userJSON, err := repository.UserJSON(pseudoUser, id, "id", "login", "creationdate", "maxtagincloud", "maxresult", "actions") + // on ne met plus les actions dans le cookie car il fini par etre trop gros et plus accepte par les navigateur (>4ko) + userJSON, err := repository.UserJSON(pseudoUser, id, "id", "login", "creationdate", "maxtagincloud", "maxresult") if err != nil { utils.Throw(w, utils.NewHTTPError500(err, pseudoUser)) return diff --git a/pkg/repository/userRepository.go b/pkg/repository/userRepository.go index cef426e..620fcb5 100644 --- a/pkg/repository/userRepository.go +++ b/pkg/repository/userRepository.go @@ -23,7 +23,7 @@ all field are send except: func UserJSON(currentUser model.BowUser, id string, fields ...string) (string, error) { var askedFields string if len(fields) == 0 { - askedFields = "id, creationdate, updatedate, login, tokens, emails, unconfirmedemailsList, authenticationinfo, autoscreenshot, autofavicon, maxtagincloud, maxresult, actions" + askedFields = "id, creationdate, updatedate, login, tokens, emails, unconfirmedemails, authenticationinfo, autoscreenshot, autofavicon, maxtagincloud, maxresult, actions" } else { askedFields = strings.Join(fields, ", ") } @@ -32,7 +32,7 @@ func UserJSON(currentUser model.BowUser, id string, fields ...string) (string, e q := &query{sql: fmt.Sprintf(` WITH unconfirmedemailsList as (select id as eid, jsonb_array_elements(unconfirmedemails)::jsonb->'email' as unconfirmedemailsList from bowuser u where id=$1), - tmp AS (select %[1]s, array_agg(unconfirmedemailsList) as unconfirmedemailsList from bowuser left join unconfirmedemailsList on eid=id where id=$1 GROUP BY %[1]s), + tmp AS (select %[1]s, array_agg(unconfirmedemailsList) as unconfirmedemails from bowuser left join unconfirmedemailsList on eid=id where id=$1 GROUP BY %[1]s), __all AS (select %[2]s from tmp) SELECT json_agg(__all.*) as j FROM __all`, allFields, askedFields)} @@ -46,6 +46,26 @@ func UserJSON(currentUser model.BowUser, id string, fields ...string) (string, e return result, nil } +/* +User return user +all field are send except: +- password +- email confirmation token +*/ +func User(currentUser model.BowUser, id string, fields ...string) (model.BowUser, error) { + var user model.BowUser + result, err := UserJSON(currentUser, id, fields...) + if err != nil { + return user, utils.NewHTTPError500(err, currentUser) + } + + err = json.Unmarshal([]byte(result), &user) + if err != nil { + return user, utils.NewHTTPError500(err, currentUser) + } + + return user, nil +} /* UserIDFromToken get user id by application token -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm