Skip to content

Commit

Permalink
Move user ytukuty functions to db/users.go
Browse files Browse the repository at this point in the history
  • Loading branch information
emmdim committed Jan 24, 2025
1 parent 06ab97c commit b48b390
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 0 additions & 18 deletions db/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions db/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b48b390

Please sign in to comment.