check user returns user type, when applicable

main
Nilo Roberto C Paim 2024-05-15 17:23:49 -03:00
parent 918f05b649
commit ede08cee1f
2 changed files with 15 additions and 11 deletions

View File

@ -214,19 +214,23 @@ func Checkuser(c *fiber.Ctx) error {
// The user is found; let's signalize this // The user is found; let's signalize this
response.Type = "U" // At first sight it's a user response.Type = "U" // At first sight it's a user
// TODO: Verify the user's type (Admin, User, Social, etc.)
if user.Channel == "" { if user.Channel == "" {
// User needs to complete the registration // User needs to complete the registration
response.Type = "RU" response.Type = "RU"
} } else {
if user.Blocked == "S" {
if user.Blocked == "S" { // User is blocked
// User is blocked response.Type = "UB"
response.Type = "UB" } else {
} if user.Cancelled == "S" {
// User is cancelled
if user.Cancelled == "S" { response.Type = "UC"
// User is cancelled } else {
response.Type = "UC" response.Type = user.UserType
}
}
} }
} }

View File

@ -14,7 +14,7 @@ type User struct {
Channel string `gorm:"size:40" json:"channel"` Channel string `gorm:"size:40" json:"channel"`
Url string `gorm:"size:40" json:"url"` Url string `gorm:"size:40" json:"url"`
CpfCnpj string `gorm:"size:20" json:"cpfcnpj"` CpfCnpj string `gorm:"size:20" json:"cpfcnpj"`
UserType string `gorm:"size:1;default:U" json:"usertype"` UserType string `gorm:"size:1;default:U" json:"usertype"` // A - Admin, U - User, S - Social
Blocked string `gorm:"size:1;default:N" json:"blocked"` Blocked string `gorm:"size:1;default:N" json:"blocked"`
Cancelled string `gorm:"size:1;default:N" json:"cancelled"` Cancelled string `gorm:"size:1;default:N" json:"cancelled"`
ServerId uint `gorm:"not null;default:1" json:"serverid"` ServerId uint `gorm:"not null;default:1" json:"serverid"`