This repository has been archived by the owner on Mar 8, 2021. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I've just implemented a remember-me feature for Friend, it's rough on the edge but the main parts are there. Could you comment about the implementation and improvements?
Thanks.
Jérémie.
Here are some notes about the implementation
Issuing a remember-me Cookie at login
interactive-form
workflow retrieve the remember-me form parameters.bcrypt-credential-fn
(through the login config),remember-me
is set to "true" thenbcrypt-credential-fn
invoke thecredentials/remember-me
function that issue new remember-me data (not the cookie yet) that will be returned through the authenticate response.remember-me
function is given asave-remember-me-fn!
as a first parameters to allow the persistent storage of the issued data. Thesave-remember-me-fn!
is defined with the login config.friend/authenticate*
function with thefriend/set-cookies-if-any
function.Authenticate with a remember-me cookie
Once issued and sent to the client, each subsequent http request will include the persistent remember-me cookie.
workflow/remember-me-hash
function workflow test if a remember-me cookie is present in the request.credentials/remember-me-hash-fn
that loads the stored remember-me data and then compare with the data provided in the cookie (validity, expiration, etc.), otherwise it returns nil and themake-auth
fn does not make it.workflow/remember-me-hash
thenmake-auth
and transmit the authenticated request to the subsequent handlerTesting
There is a dedicated test
functional/user-login-with-remember-me-cookie-set
.