Topic: checking to see is activated
So the short of it is I am implementing a simple email activation and have successfully been able to create an activation key in the column. The key is then replaced with null when the email is activated. I am having trouble with the logic to authenticate account activation. The model code is below...
def self.authenticate(email, submitted_password) user = find_by_email(email) return nil if user.nil? return false if user.activated != null return user if user.has_password?(submitted_password) end
and the controller code is
def create user = User.authenticate(params[:session][:email], params[:session][:password]) if user.nil? flash.now[:error] = "Invalid email/password combination." @title = "Sign in" render 'new' elsif user == 1 flash.now[:error] = "The account you are attempting to log into has not been activated, please check your email." @title = "Sign in" render 'new' else sign_in(user,params[:session][:permanent]) redirect_back_or dashboard_path end end