gauth/user/creation
Types
An error that occurs during user creation
pub type UserCreationError {
InvalidName(name: String, reason: String)
Generic(message: String)
}
Constructors
-
InvalidName(name: String, reason: String)
The name provided was invalid, the reason must be a human readable explanation of what went wrong
-
Generic(message: String)
A catch all error type for when something goes wrong IE the data source is unreachable
A service to create users Do not interact with the create_user function directly, instead use the create_user function provided by this module
pub type UserCreationService(identifier) {
UserCreationService(
create_user: fn(String) -> User(identifier),
middleware: List(
fn(String) -> Result(String, UserCreationError),
),
finalware: List(fn(User(identifier)) -> User(identifier)),
errorware: List(fn(UserCreationError) -> UserCreationError),
)
}
Constructors
-
UserCreationService( create_user: fn(String) -> User(identifier), middleware: List( fn(String) -> Result(String, UserCreationError), ), finalware: List(fn(User(identifier)) -> User(identifier)), errorware: List(fn(UserCreationError) -> UserCreationError), )
Functions
pub fn create_user(
user: String,
service: UserCreationService(a),
) -> Result(User(a), UserCreationError)
Creates a user with the given name by:
- Applying all middleware in sequence
- Creating the user via the service’s create_user function
- Applying all finalware in sequence
- Returning the user The name is not checked for validity, to add this please look into middleware Any errors will first go through all errorware in sequence before being returned
pub fn with_errorware(
service: UserCreationService(a),
errorware: fn(UserCreationError) -> UserCreationError,
) -> UserCreationService(a)
Adds an errorware to the service The provided errorware is appended at the start of the errorware list
pub fn with_finalware(
service: UserCreationService(a),
finalware: fn(User(a)) -> User(a),
) -> UserCreationService(a)
Adds a finalware to the service The provided finalware is appended at the start of the finalware list
pub fn with_middleware(
service: UserCreationService(a),
middleware: fn(String) -> Result(String, UserCreationError),
) -> UserCreationService(a)
Adds a middleware to the service The provided middleware is appended at the start of the middleware list