app/controllers/sessions_controller.rb
# log in user after authenticating and set 'remember me' token
# redirect to last page visited or else user show page
log in user after authenticating and set 'remember me' token
redirect to last page visited or else user show page
log in user after authenticating and set ' remember me ' token redirect to last page visited or else user show page
def create
  	@user = User.find_by(email: params[:session][:email].downcase)
  	if @user && @user.authenticate(params[:session][:password])
      if @user.activated?
    		log_in @user
    		params[:session][:remember_me] == '1' ? remember(@user) : forget(@user)
    		redirect_back_or @user
      else
        message = "Account not activated. "
        message += "Check your email for the activation link."
        flash[:warning] = message
        redirect_to root_url
      end
  	else
  		flash.now[:danger] = 'Invalid email/password combination'
  		render 'new'
  	end
  end
def create @user = User . find_by ( email : params [ :session ] [ :email ] . downcase ) if @user && @user . authenticate ( params [ :session ] [ :password ] ) if @user . activated? log_in @user params [ :session ] [ :remember_me ] == '1' ? remember ( @user ) : forget ( @user ) redirect_back_or @user else message = "Account not activated. " message += "Check your email for the activation link." flash [ :warning ] = message redirect_to root_url end else flash . now [ :danger ] = 'Invalid email/password combination' render 'new' end end
log in user after authenticating and set 'remember me' token
redirect to last page visited or else user show page
log in user after authenticating and set ' remember me ' token redirect to last page visited or else user show page