app/controllers/peoplefinder/tokens_controller.rb in peoplefinder-0.0.2 vs app/controllers/peoplefinder/tokens_controller.rb in peoplefinder-0.1.0
- old
+ new
@@ -1,9 +1,10 @@
module Peoplefinder
class TokensController < ApplicationController
skip_before_action :ensure_user
before_action :set_desired_path, only: [:show]
+ before_action :ensure_token_auth_enabled!
def create
@token = Token.new(token_params)
if @token.save
TokenMailer.new_token_email(@token).deliver
@@ -21,9 +22,15 @@
session['current_user_id'] = person.id
redirect_to_desired_path
end
protected
+
+ def ensure_token_auth_enabled!
+ return if feature_enabled?('token_auth')
+ flash[:notice] = t('.token_auth_disabled')
+ redirect_to(new_sessions_path)
+ end
def token_params
params.require(:token).permit([:user_email])
end