{-# language NoFieldSelectors #-}

-- | Description: Authed account data type
module Polysemy.Account.Data.AuthedAccount where

import Polysemy.Account.Data.AccountName (AccountName)
import Polysemy.Account.Data.AccountStatus (AccountStatus)
import Polysemy.Account.Data.Privilege (Privilege)

-- | An account an the ID of the password used to authenticate it.
data AuthedAccount i p =
  AuthedAccount {
    forall i p. AuthedAccount i p -> i
id :: i,
    forall i p. AuthedAccount i p -> i
authId :: i,
    forall i p. AuthedAccount i p -> AccountName
name :: AccountName,
    forall i p. AuthedAccount i p -> AccountStatus
status :: AccountStatus,
    forall i p. AuthedAccount i p -> p
privileges :: p
  }
  deriving stock (AuthedAccount i p -> AuthedAccount i p -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall i p.
(Eq i, Eq p) =>
AuthedAccount i p -> AuthedAccount i p -> Bool
/= :: AuthedAccount i p -> AuthedAccount i p -> Bool
$c/= :: forall i p.
(Eq i, Eq p) =>
AuthedAccount i p -> AuthedAccount i p -> Bool
== :: AuthedAccount i p -> AuthedAccount i p -> Bool
$c== :: forall i p.
(Eq i, Eq p) =>
AuthedAccount i p -> AuthedAccount i p -> Bool
Eq, Int -> AuthedAccount i p -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall i p. (Show i, Show p) => Int -> AuthedAccount i p -> ShowS
forall i p. (Show i, Show p) => [AuthedAccount i p] -> ShowS
forall i p. (Show i, Show p) => AuthedAccount i p -> String
showList :: [AuthedAccount i p] -> ShowS
$cshowList :: forall i p. (Show i, Show p) => [AuthedAccount i p] -> ShowS
show :: AuthedAccount i p -> String
$cshow :: forall i p. (Show i, Show p) => AuthedAccount i p -> String
showsPrec :: Int -> AuthedAccount i p -> ShowS
$cshowsPrec :: forall i p. (Show i, Show p) => Int -> AuthedAccount i p -> ShowS
Show, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall i p x. Rep (AuthedAccount i p) x -> AuthedAccount i p
forall i p x. AuthedAccount i p -> Rep (AuthedAccount i p) x
$cto :: forall i p x. Rep (AuthedAccount i p) x -> AuthedAccount i p
$cfrom :: forall i p x. AuthedAccount i p -> Rep (AuthedAccount i p) x
Generic)

json ''AuthedAccount

-- | Convenience alias for using the default privilege type with 'AuthedAccount'.
type AuthedAccountP i = AuthedAccount i [Privilege]