From eb18a1f737fc6bbb559998e12ad710981cab0249 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Tue, 24 Sep 2019 12:22:30 +0300 Subject: [PATCH] Make key level tags in order and unique (#2475) Fixes TykTechnologies/tyk-analytics#1413 FE task: TykTechnologies/tyk-analytics-ui#1082 (cherry picked from commit f2f74d9) --- middleware.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/middleware.go b/middleware.go index e2732dee49a..e4b7c6e5ae2 100644 --- a/middleware.go +++ b/middleware.go @@ -421,11 +421,13 @@ func (t BaseMiddleware) ApplyPolicies(session *user.SessionState) error { } } - // set tags - if len(tags) > 0 { - for tag := range tags { - session.Tags = append(session.Tags, tag) - } + for _, tag := range session.Tags { + tags[tag] = true + } + + session.Tags = []string{} + for tag, _ := range tags { + session.Tags = append(session.Tags, tag) } session.AccessRights = rights