How to authenticate with warden.authenticate!

I want to do "login or register" on the fly by posting a comment on my forum. I am using Devise / Warden.

I want to do something like this:

user = warden.authenticate!(params[:email], params[:password]) sign_in(:user, user) 

Can someone give me some tips on how to do this?

Thanks!

+4
source share
3 answers

Enable: you can register, but no: confirmation in your model.

0
source

Warden has a helper method set_user . Therefore, you should be able to:

warden.set_user(@user, scope: :user)

You can probably define a helper method for the controller to sign the user and redirect him to the desired path.

Additional information is available at: https://github.com/hassox/warden/wiki/Authenticated-session-data

0
source

I know this is an old topic, but I worked with

 # Inside SessionController < Devise::SessionsController def create self.resource = warden.authenticate!(auth_options) sign_in(resource_name, resource) # this will set cookie end 

It was developed specifically, but when checking the auth_options method in controller development, I found this code fragment here :

 # File 'app/controllers/devise/sessions_controller.rb', line 45 def auth_options { scope: resource_name, recall: "#{controller_path}#new" } end 

Hope this helps.

0
source

Source: https://habr.com/ru/post/1333752/


All Articles