package model

import (
    "database/sql"
    "time"
)

const COOKIE_TOKEN string = "AM_SESSION"
const MAX_LOGIN_FAIL_ATTEMPTS int = 3

type (
    Account struct {
        ID              string          `json:"id" db:"id"`
        Username        string          `json:"username" db:"username"`
        Password        string          `json:"password" db:"password"`
        Email           sql.NullString  `json:"email" db:"email"`
        AvatarURL       sql.NullString  `json:"avatar_url" db:"avatar_url"`
        CreatedAt       time.Time       `json:"created_at" db:"created_at"`
        FailAttempts    int                `json:"fail_attempts" db:"fail_attempts"`
        Locked            bool            `json:"locked" db:"locked"`

        Privileges  []AccountPrivilege  `json:"privileges"`
    }

    AccountPrivilege string
)

const (
    Root AccountPrivilege = "root" // grants all permissions. very dangerous to grant!

    // unused for now
    CreateInvites AccountPrivilege = "create_invites"
    ReadAccounts AccountPrivilege = "read_accounts"
    EditAccounts AccountPrivilege = "edit_accounts"

    ReadReleases AccountPrivilege = "read_releases"
    EditReleases AccountPrivilege = "edit_releases"

    ReadTracks AccountPrivilege = "read_tracks"
    EditTracks AccountPrivilege = "edit_tracks"

    ReadArtists AccountPrivilege = "read_artists"
    EditArtists AccountPrivilege = "edit_artists"
)
