Class: Decidim::Kids::AuthorizationsController
- Inherits:
-
Verifications::AuthorizationsController
- Object
- Verifications::AuthorizationsController
- Decidim::Kids::AuthorizationsController
- Includes:
- NeedsTutorAuthorization, UserProfile
- Defined in:
- app/controllers/decidim/kids/authorizations_controller.rb
Instance Method Summary collapse
- #authorizations_path(prs = {}) ⇒ Object
- #create ⇒ Object
- #handler_name ⇒ Object
- #handler_params ⇒ Object
- #index ⇒ Object
- #minor_authorized? ⇒ Boolean
- #minor_user ⇒ Object
- #new ⇒ Object
Instance Method Details
#authorizations_path(prs = {}) ⇒ Object
13 14 15 |
# File 'app/controllers/decidim/kids/authorizations_controller.rb', line 13 def (prs = {}) decidim_kids.(prs) end |
#create ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/decidim/kids/authorizations_controller.rb', line 36 def create if flash[:notice] = t("authorizations.authorize.already_authorized", scope: "decidim.kids") return redirect_to decidim_kids.user_minors_path end AuthorizeMinor.call(handler) do on(:ok) do flash[:notice] = t("authorizations.authorize.success", scope: "decidim.kids") redirect_to redirect_url || end on(:transferred) do flash[:notice] = t("authorizations.authorize.success", scope: "decidim.kids") redirect_to redirect_url || end on(:invalid_age) do flash[:alert] = t("authorizations.create.invalid_age", scope: "decidim.kids") render action: :new end on(:invalid) do flash[:alert] = t("authorizations.authorize.error", scope: "decidim.kids") render action: :new end end end |
#handler_name ⇒ Object
69 70 71 |
# File 'app/controllers/decidim/kids/authorizations_controller.rb', line 69 def handler_name current_organization. end |
#handler_params ⇒ Object
65 66 67 |
# File 'app/controllers/decidim/kids/authorizations_controller.rb', line 65 def handler_params (params[:authorization_handler] || {}).merge(user: minor_user) end |
#index ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/decidim/kids/authorizations_controller.rb', line 17 def index if # TODO: unblock user, update personal data flash[:notice] = t("authorizations.authorize.success", scope: "decidim.kids") else flash[:alert] = t("authorizations.authorize.error", scope: "decidim.kids") end redirect_to decidim_kids.user_minors_path end |
#minor_authorized? ⇒ Boolean
77 78 79 |
# File 'app/controllers/decidim/kids/authorizations_controller.rb', line 77 def (minor_user).present? end |
#minor_user ⇒ Object
73 74 75 |
# File 'app/controllers/decidim/kids/authorizations_controller.rb', line 73 def minor_user current_user.minors.find(params[:user_minor_id]) end |
#new ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/controllers/decidim/kids/authorizations_controller.rb', line 27 def new if flash[:notice] = t("authorizations.authorize.already_authorized", scope: "decidim.kids") redirect_to decidim_kids.user_minors_path else super end end |