Added better Tenanting

* Removed Tenanting from base objects as some models may be tenantless
* Admins are naturally not restricted by tenants
* Users *ARE* the tenants (for now) so they don't require a tenant ID
either
* User-owned models should all include the Tenanted model as their base
* Created .Create and .Save methods attached to base model
This commit is contained in:
🐙PiperYxzzy
2022-05-01 12:48:40 +02:00
parent 8ab45e2401
commit dd8d2a677d
3 changed files with 25 additions and 11 deletions

View File

@@ -11,7 +11,7 @@ import (
type User struct {
Auth
Email string `gorm:"unique" sql:"index"`
Email string `gorm:"unique;index"`
}
const userJwtDuration = time.Hour * 24
@@ -24,7 +24,6 @@ func (u *User) GetJwt() (string, int) {
"iat": time.Now().Unix(),
"exp": time.Now().Add(userJwtDuration).Unix(),
"role": "user",
"tid": u.Tenant.String(),
})
jstr, err := j.SignedString(UserHmac)