diff auth/session.go @ 326:a7b2db8b3d18

Added type for roles.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 02 Aug 2018 18:39:01 +0200
parents f345edb409b2
children e48da6f427c8
line wrap: on
line diff
--- a/auth/session.go	Thu Aug 02 18:07:35 2018 +0200
+++ b/auth/session.go	Thu Aug 02 18:39:01 2018 +0200
@@ -7,11 +7,22 @@
 	"time"
 )
 
+type Roles []string
+
 type Session struct {
-	ExpiresAt int64    `json:"expires"`
-	User      string   `json:"user"`
-	Password  string   `json:"password"`
-	Roles     []string `json:"roles"`
+	ExpiresAt int64  `json:"expires"`
+	User      string `json:"user"`
+	Password  string `json:"password"`
+	Roles     Roles  `json:"roles"`
+}
+
+func (r Roles) Has(role string) bool {
+	for _, x := range r {
+		if x == role {
+			return true
+		}
+	}
+	return false
 }
 
 const (