app/controllers/users_controller.rb in tkh_authentication-0.1.11 vs app/controllers/users_controller.rb in tkh_authentication-0.9
- old
+ new
@@ -1,10 +1,10 @@
class UsersController < ApplicationController
-
+
before_filter :authenticate, only: 'index'
- before_filter :authenticate_with_admin, except: ['new', 'create', 'detect_existence']
-
+ before_filter :authenticate_with_admin, except: ['new', 'create']
+
def index
@users = User.by_recent
render layout: 'admin'
end
@@ -21,46 +21,27 @@
session[:target_page] = nil
else
render "new"
end
end
-
- def detect_existence
- set_target_page
- @detected_email = params[:user][:email]
- user = User.where('email = ?',@detected_email).first
- if user && !user.password_digest.blank? && user.password != 'temporary'
- flash[:notice] = "Our records show you have an account with us. Please login."
- redirect_to login_path(email: @detected_email)
- else
- if user
- newbie = Newbie.where('email = ?', params[:user][:email]).first
- else
- newbie = Newbie.create(email: params[:user][:email])
- end
- newbie.send_password_set
- flash[:notice] = "Our records show you do not have an account with us. We need to verify your email address. Please check your email inbox (or spam filter if you have nothing after several minutes) and click on the confirmation link."
- redirect_to safe_root_url
- end
- end
-
+
def make_admin
user = User.find(params[:id])
user.admin = true
user.save
redirect_to users_path, notice: t('authentication.admin_enabled_confirmation')
end
-
+
def remove_admin
user = User.find(params[:id])
user.admin = false
user.save
redirect_to users_path, notice: t('authentication.admin_disabled_confirmation')
end
-
+
private
-
+
def set_target_page
session[:target_page] = request.referer unless session[:target_page] # && !request.referer.nil?
end
-
+
end