-
Notifications
You must be signed in to change notification settings - Fork 4
Using a custom current_user_getter
If you're not using Devise/Warden for authentication, you'll need to provide a method for Preact to access the identity information about the current user. Ideally, this will be a method or variable in your application_controller which returns the User model.
If you already have a method like get_the_logged_in_user
which returns a model, then this is very easy. Simply uncomment the following line in preact.yml and replace with the name of the method or instance variable. Remember to prefix an instance variable with the @ symbol.
current_user_getter: "get_the_logged_in_user"
Then you will also want to add a to_preact
method to the model returned by that method. See the quickstart for those instructions.
If you don't already have a method to return the current user, simply create one in your application_controller and then jump up to Option 1 above.
Easy