From b48b39006c5b89045dd508c12c845a339ea554e4 Mon Sep 17 00:00:00 2001 From: emmdim Date: Fri, 24 Jan 2025 12:03:59 +0100 Subject: [PATCH] Move user ytukuty functions to db/users.go --- db/types.go | 18 ------------------ db/users.go | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/db/types.go b/db/types.go index 5e3e7c1..bbdf647 100644 --- a/db/types.go +++ b/db/types.go @@ -23,24 +23,6 @@ type UserVerification struct { Expiration time.Time `json:"expiration" bson:"expiration"` } -func (u *User) HasRoleFor(address string, role UserRole) bool { - for _, org := range u.Organizations { - if org.Address == address && string(org.Role) == string(role) { - return true - } - } - return false -} - -func (u *User) IsMemberOf(address string) bool { - for _, org := range u.Organizations { - if org.Address == address { - return true - } - } - return false -} - type UserRole string type OrganizationType string diff --git a/db/users.go b/db/users.go index 5c236d7..9b5ded0 100644 --- a/db/users.go +++ b/db/users.go @@ -11,6 +11,24 @@ import ( "go.vocdoni.io/dvote/log" ) +func (u *User) HasRoleFor(address string, role UserRole) bool { + for _, org := range u.Organizations { + if org.Address == address && string(org.Role) == string(role) { + return true + } + } + return false +} + +func (u *User) IsMemberOf(address string) bool { + for _, org := range u.Organizations { + if org.Address == address { + return true + } + } + return false +} + // nextUserID internal method returns the next available user ID. If an error // occurs, it returns the error. This method must be called with the keysLock // held.