Module | Devise::Controllers::Helpers |
In: |
lib/devise/controllers/helpers.rb
|
Those helpers are convenience methods added to ApplicationController.
The default url to be used after signing in. This is used by all Devise controllers and you can overwrite it in your ApplicationController to provide a custom hook for a custom resource.
By default, it first tries to find a valid resource_return_to key in the session, then it fallbacks to resource_root_path, otherwise it uses the root path. For a user scope, you can define the default url in the following way:
map.user_root '/users', :controller => 'users' # creates user_root_path map.namespace :user do |user| user.root :controller => 'users' # creates user_root_path end
If the resource root path is not defined, root_path is used. However, if this default is not enough, you can customize it, for example:
def after_sign_in_path_for(resource) stored_location_for(resource) || if resource.is_a?(User) && resource.can_publish? publisher_url else signed_in_root_path(resource) end end
Method used by sessions controller to sign out a user. You can overwrite it in your ApplicationController to provide a custom hook for a custom scope. Notice that differently from after_sign_in_path_for this method receives a symbol with the scope, and not the resource.
By default it is the root_path.
Tell warden that params authentication is allowed for that specific page.
Return true if it‘s a devise_controller. false to all controllers unless the controllers defined inside devise. Useful if you want to apply a before filter to all controllers, except the ones in devise:
before_filter :my_filter, :unless => { |c| c.devise_controller? }
Overwrite Rails’ handle unverified request to sign out all scopes, clear run strategies and remove cached variables.
Sign in a user that already was authenticated. This helper is useful for logging users in after sign up.
All options given to sign_in is passed forward to the set_user method in warden. The only exception is the :bypass option, which bypass warden callbacks and stores the user straight in session. This option is useful in cases the user is already signed in, but we want to refresh the credentials in session.
Examples:
sign_in :user, @user # sign_in(scope, resource) sign_in @user # sign_in(resource) sign_in @user, :event => :authentication # sign_in(resource, options) sign_in @user, :bypass => true # sign_in(resource, options)
Sign in a user and tries to redirect first to the stored location and then to the url specified by after_sign_in_path_for. It accepts the same parameters as the sign_in method.
Sign out a given user or scope. This helper is useful for signing out a user after deleting accounts.
Examples:
sign_out :user # sign_out(scope) sign_out @user # sign_out(resource)
Sign out all active users or scopes. This helper is useful for signing out all roles in one click. This signs out ALL scopes in warden.
Sign out a user and tries to redirect to the url specified by after_sign_out_path_for.
Return true if the given scope is signed in session. If no scope given, return true if any scope is signed in. Does not run authentication hooks.
The scope root url to be used when he‘s signed in. By default, it first tries to find a resource_root_path, otherwise it uses the root_path.