From b48a610e9063c2a1ba6f3615f75113e6e036e604 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Thu, 31 Jul 2025 22:08:54 +0100 Subject: [PATCH] add roles --- internal/auth/types.go | 14 ++++++++------ internal/types/errors.go | 25 ++++++++++++------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/internal/auth/types.go b/internal/auth/types.go index 3f2051c..ce06067 100644 --- a/internal/auth/types.go +++ b/internal/auth/types.go @@ -32,12 +32,14 @@ type TokenResponse struct { } type User struct { - ID string `json:"id" gorm:"primaryKey"` - Username string `json:"username"` - Blacklisted bool `json:"blacklisted"` - Email string `json:"email"` - CreatedAt time.Time `json:"created_at"` - HashedApiKey string `json:"hashed_api_key"` + ID string `json:"id" gorm:"primaryKey"` + Username string `json:"username"` + Blacklisted bool `json:"blacklisted"` + Email string `json:"email"` + CreatedAt time.Time `json:"created_at"` + HashedApiKey string `json:"hashed_api_key"` + Role string `json:"role" gorm:"default:'free'"` // free, pro, pro+, admin + SubscriptionExpiresAt time.Time `json:"subscription_expires_at"` } type AvatarDecorationData struct { diff --git a/internal/types/errors.go b/internal/types/errors.go index ec42289..f0d9b4c 100644 --- a/internal/types/errors.go +++ b/internal/types/errors.go @@ -1,23 +1,22 @@ /* - Copyright (C) 2025 hexlocation (hex@iwakura.rip) & grngxd (grng@iwakura.rip) + Copyright (C) 2025 hexlocation (hex@iwakura.rip) & grngxd (grng@iwakura.rip) - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ package types import ( - "errors" "fmt" "github.com/gin-gonic/gin" @@ -37,7 +36,7 @@ func (e *StereoError) Throw(c *gin.Context, err error) { if err != nil { c.Error(err) } else { - c.Error(errors.New(fmt.Sprintf("Got an error with code: %v", e.Code))) + c.Error(fmt.Errorf("got an error with code: %v", e.Code)) } }