gauth/user/deletion

Types

An error relating to the deletion of a user

pub type UserDeletionError(identifier) {
  NoSuchUser(id: identifier)
  Generic(message: String)
}

Constructors

  • NoSuchUser(id: identifier)

    The user requested to be deleted does not exist

  • Generic(message: String)

    A generic error such as the data source being unreachable

The deletion service for a user Do not interact with the delete_user function directly, instead use the delete_user function provided by this module

pub type UserDeletionService(identifier) {
  UserDeletionService(
    delete_user: fn(identifier) ->
      Result(Nil, UserDeletionError(identifier)),
    middleware: List(
      fn(identifier) ->
        Result(identifier, UserDeletionError(identifier)),
    ),
    errorware: List(
      fn(UserDeletionError(identifier)) ->
        UserDeletionError(identifier),
    ),
  )
}

Constructors

  • UserDeletionService(
      delete_user: fn(identifier) ->
        Result(Nil, UserDeletionError(identifier)),
      middleware: List(
        fn(identifier) ->
          Result(identifier, UserDeletionError(identifier)),
      ),
      errorware: List(
        fn(UserDeletionError(identifier)) ->
          UserDeletionError(identifier),
      ),
    )

Functions

pub fn delete_user(
  user: a,
  service: UserDeletionService(a),
) -> Result(Nil, UserDeletionError(a))

Deletes the user with the given identifier by:

  • Applying all middleware in sequence
  • Deleting the user via the service’s delete_user function Any errors will first go through all errorware in sequence before being returned
pub fn with_errorware(
  service: UserDeletionService(a),
  errorware: fn(UserDeletionError(a)) -> UserDeletionError(a),
) -> UserDeletionService(a)

Adds an errorware to the service The provided errorware is appended at the start of the errorware list

pub fn with_middleware(
  service: UserDeletionService(a),
  middleware: fn(a) -> Result(a, UserDeletionError(a)),
) -> UserDeletionService(a)

Adds a middleware to the service The provided middleware is appended at the start of the middleware list

Search Document