Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where is devise implementation of "authenticate_user!" method?

Where is devise implementation of authenticate_user! method?

I have been looking for it and have not found it so far.

like image 883
Greg Avatar asked Feb 14 '12 05:02

Greg


People also ask

What does devise Authenticate_user do?

This allows all users to access the index route, but only authenticated users could access other routes in the comments controller. Note that :authenticate_user! is a method provided by Devise, so if you're using Bcrypt, you'll have to create your own custom method.

Where is device controller in Rails?

Below one is for Rails 5 -> app/views/users/CONTROLLER/... when you do this so that your new controller can find them.

What is devise warden?

Warden is a gem that takes care of fetching authentication details from the request and fetching the user. Devise requires Warden to be added as a middleware.


1 Answers

It's in lib/devise/controllers/helpers.rb1 and is generated dynamically (user being only one of the possible suffixes):

def self.define_helpers(mapping) #:nodoc:     mapping = mapping.name      class_eval <<-METHODS, __FILE__, __LINE__ + 1       def authenticate_#{mapping}!(opts={})         opts[:scope] = :#{mapping}         warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)       end        def #{mapping}_signed_in?         !!current_#{mapping}       end        def current_#{mapping}         @current_#{mapping} ||= warden.authenticate(:scope => :#{mapping})       end        def #{mapping}_session         current_#{mapping} && warden.session(:#{mapping})       end     METHODS      ActiveSupport.on_load(:action_controller) do       helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session"     end   end 
like image 192
jupp0r Avatar answered Oct 14 '22 19:10

jupp0r