add roles

This commit is contained in:
grngxd 2025-07-31 22:08:54 +01:00
parent 8ca089ecfb
commit b48a610e90
2 changed files with 20 additions and 19 deletions

View file

@ -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 {

View file

@ -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 <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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))
}
}