Class: EgovUtils::UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- EgovUtils::UsersController
- Defined in:
- app/controllers/egov_utils/users_controller.rb
Instance Method Summary collapse
- #approve ⇒ Object
- #confirm ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
Instance Method Details
#approve ⇒ Object
53 54 55 56 57 58 59 |
# File 'app/controllers/egov_utils/users_controller.rb', line 53 def approve @user = User.find_by(id: params[:id]) render_404 and return unless @user || @user.active? (:manage, User) @user.update(active: true) redirect_back(fallback_location: @user) end |
#confirm ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'app/controllers/egov_utils/users_controller.rb', line 61 def confirm @user = User.find_by(confirmation_code: params[:id]) render_404 and return unless @user || @user.active? || @user.updated_at < (Time.now - 24.hours) @user.update(active: true) logged_user = @user flash[:notice] = t('success_user_confirm') redirect_to('/') end |
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/egov_utils/users_controller.rb', line 22 def create @user.mail ||= @user.login respond_to do |format| if @user.save if EgovUtils::Settings.allow_register? && !current_user.logged? UserMailer.confirmation_email(@user).deliver_later flash[:notice] = t('notice_signeup_with_mail') else if @user.auth_source.nil? @user.update(active: true) UserMailer.account_information(@user, @user.password).deliver_later end flash[:notice] = t('activerecord.successful.messages.created', model: User.model_name.human) end format.html{ redirect_to main_app.root_path } format.json{ render json: @user, status: :created } else format.html{ render 'new' } format.json{ render json: @user.errors., status: :unprocessable_entity } end end end |
#destroy ⇒ Object
48 49 50 51 |
# File 'app/controllers/egov_utils/users_controller.rb', line 48 def destroy @user.destroy redirect_to users_path, notice: t('activerecord.successful.messages.destroyed', model: User.model_name.human) end |
#index ⇒ Object
12 13 14 15 16 17 |
# File 'app/controllers/egov_utils/users_controller.rb', line 12 def index providers @users = EgovUtils::User.accessible_by(current_ability).order(:provider) @groups = EgovUtils::Group.accessible_by(current_ability).order(:provider) @new_user = EgovUtils::User.new(generate_password: true) end |
#new ⇒ Object
19 20 |
# File 'app/controllers/egov_utils/users_controller.rb', line 19 def new end |
#search ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/egov_utils/users_controller.rb', line 70 def search (:read, User) (:read, Group) user_results = []; group_results = [] providers.each do |provider| user_results.concat( provider.search_user(params[:q]) ) group_results.concat( provider.search_group(params[:q]) ) end if params[:q].present? respond_to do |format| format.json{ render json: {users: user_results, groups: group_results} } end end |
#show ⇒ Object
45 46 |
# File 'app/controllers/egov_utils/users_controller.rb', line 45 def show end |