RestAuth v1.1.1 RestAuth.Controller View Source
Generic controller handling login and logout.
Link to this section Summary
Functions
Call this function from your authentication controller
Call this function from your authentication controller
Link to this section Functions
Call this function from your authentication controller.
It will write the token to a cookie if handler is configured to write cookies.
The function will respond either successfully with data from the authority
struct returned by the RestAuth.Handler.load_user_data/2
callback:
{
"data": {
"token": "g3QAAAACZAAEZGF0YW....udlCH1tpI8oPfIE+BsMcrXj2A=",
"user_id": 1,
"roles": ["user", "admin"],
"metadata": {"name": "John Doe"}
}
}
Or with the returned error:
{
"error": <your string here>
}
Example
def login(conn, params) do
RestAuth.Controller.login(conn, params)
end
Call this function from your authentication controller.
It will write the token to a cookie if handler is set to write cookies.
Your handler module can have an optional cookie_params/0
function to send params to put_resp_cookie/4
.
Example
def logout(conn, params) do
RestAuth.Controller.logout(conn)
end