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
response.Type = "U" // At first sight it's a user
// TODO: Verify the user's type (Admin, User, Social, etc.)
if user.Channel == "" {
// User needs to complete the registration
response.Type = "RU"
}
if user.Blocked == "S" {
// User is blocked
response.Type = "UB"
}
if user.Cancelled == "S" {
// User is cancelled
response.Type = "UC"
} else {
if user.Blocked == "S" {
// User is blocked
response.Type = "UB"
} else {
if user.Cancelled == "S" {
// User is cancelled
response.Type = "UC"
} else {
response.Type = user.UserType
}
}
}
}

View File

@ -14,7 +14,7 @@ type User struct {
Channel string `gorm:"size:40" json:"channel"`
Url string `gorm:"size:40" json:"url"`
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"`
Cancelled string `gorm:"size:1;default:N" json:"cancelled"`
ServerId uint `gorm:"not null;default:1" json:"serverid"`