smr/doc/hooks.md

24 lines
849 B
Markdown

!{ md
@file doc/hooks
# Hooks
Various functions that are exposed to the lua environment. These functions may be detoured to effect their behavior.
```
connect(req :: http_request) :: boolean
```
Called before smr business logic is run, may run additional validation on the request. Return @{falsey} by default, and continues onto the business logic of smr, return `true` if this function has handled the request, and no further processing is nessessary.
```
create_user(details :: table) :: boolean
```
Called when a user creates a user account on the site.
```
authenticate(data :: table) :: number | nil, string
```
Called when a user attempts to log in. Return a number, userid if the login is successful, or nil and an error message if the login is not successful. By default, smr puts "user" and "passfile" fields into the data table.
!}