jeudi 5 mars 2015

Check if user is authenticated with Ruby on Rails Devise

Im using Rails 4 and Devise 3


I am overwriting the sessions controller. For creating a session, I would like to check if user is confirmed first or not, but I'm not sure how to check if the user is confirmed. This is what I would like to do:


sessions controller



def create
if USER_CONFIRMED??
return render :json => {:success => false, :type => "signin", :errors => ["You have to confirm your email address before continuing."]}
else
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure")
sign_in_and_redirect(resource_name, resource)
end
end


Thank you.


Aucun commentaire:

Enregistrer un commentaire