package models

import (
	"time"

	"go.mongodb.org/mongo-driver/v2/bson"
)

const (
	RoleOwner  = "owner"
	RoleAdmin  = "admin"
	RoleMember = "member"
)

func ValidRole(role string) bool {
	switch role {
	case RoleOwner, RoleAdmin, RoleMember:
		return true
	}
	return false
}

type User struct {
	ID           bson.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
	UserID       string        `bson:"user_id" json:"user_id"`
	InstanceID   string        `bson:"instance_id" json:"instance_id"`
	Email        string        `bson:"email" json:"email"`
	PasswordHash string        `bson:"password_hash,omitempty" json:"-"`
	Role         string        `bson:"role" json:"role"`
	AuthSource   string        `bson:"auth_source" json:"auth_source"`
	CreatedAt    time.Time     `bson:"created_at" json:"created_at"`
	LastLogin    *time.Time    `bson:"last_login,omitempty" json:"last_login,omitempty"`
}
