A
A
Alexander2015-12-28 02:45:05
Ruby on Rails
Alexander, 2015-12-28 02:45:05

How to override Devise authentication in Rails?

The fact is that the user is not deleted after deletion, and the visible field takes on the value of zero. I do not know how to check for an additional parameter. Tried like this:

class Users::SessionsController < Devise::SessionsController
  layout "devise"

  # POST /resource/sign_in
  def create
    @user = User.find_by_email(params[:user][:email])
    if @user.visible == 0
     flash[:notice] = "#{ @user.email } do not have portal access."
     redirect_to :controller => 'welcome'
   else
    super
  end

end

but doesn't work...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Kozhin, 2015-12-28
@kkzhn

And in routes.rb they indicated which controller to use for sessions?
It's done something like this:

devise_for :users, controllers: {sessions: 'users/sessions'}

A
Alexander, 2015-12-28
@savio

Thank you! exactly, I forgot to sit and suffer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question