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
54 55 56 57 58 59 60 |
# File 'app/controllers/egov_utils/users_controller.rb', line 54 def approve @user = User.find_by(id: params[:id]) render_404 and return if @user.nil? || @user.active? (:manage, User) @user.update(active: true) redirect_back(fallback_location: @user) end |
#confirm ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'app/controllers/egov_utils/users_controller.rb', line 62 def confirm @user = User.find_by(confirmation_code: params[:id]) render_404 and return if @user.nil? || @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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/egov_utils/users_controller.rb', line 23 def create @user.mail ||= @user.login respond_to do |format| if @user.save if EgovUtils::Settings.allow_register? && !current_user.logged? UserMailer.with(host: mailer_host).confirmation_email(@user).deliver_later flash[:notice] = t('notice_signeup_with_mail') else if @user.auth_source.nil? @user.update(active: true) UserMailer.with(host: mailer_host).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
49 50 51 52 |
# File 'app/controllers/egov_utils/users_controller.rb', line 49 def destroy @user.destroy redirect_to users_path, notice: t('activerecord.successful.messages.destroyed', model: User.model_name.human) end |
#index ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/controllers/egov_utils/users_controller.rb', line 11 def index providers @groups = EgovUtils::Group.accessible_by(current_ability).order(:provider) @new_user = EgovUtils::User.new(generate_password: true) azahara_schema_index do |users| users.add_sort('provider') end end |
#new ⇒ Object
20 21 |
# File 'app/controllers/egov_utils/users_controller.rb', line 20 def new end |
#search ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/egov_utils/users_controller.rb', line 71 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
46 47 |
# File 'app/controllers/egov_utils/users_controller.rb', line 46 def show end |