Module: Account::Controllers::Base
- Extended by:
- ActiveSupport::Concern
- Included in:
- ApplicationController
- Defined in:
- app/controllers/concerns/account/controllers/base.rb
Instance Method Summary collapse
- #accepting_invitation? ⇒ Boolean
- #adding_team? ⇒ Boolean
- #adding_user_details? ⇒ Boolean
- #adding_user_email? ⇒ Boolean
- #ensure_onboarding_is_complete ⇒ Object
- #ensure_onboarding_is_complete_and_set_next_step ⇒ Object
- #managing_account? ⇒ Boolean
- #set_last_seen_at ⇒ Object
- #switching_teams? ⇒ Boolean
Instance Method Details
#accepting_invitation? ⇒ Boolean
54 55 56 |
# File 'app/controllers/concerns/account/controllers/base.rb', line 54 def accepting_invitation? (params[:controller] == "account/invitations") && (params[:action] == "show" || params[:action] == "accept") end |
#adding_team? ⇒ Boolean
39 40 41 42 43 |
# File 'app/controllers/concerns/account/controllers/base.rb', line 39 def adding_team? return true if request.get? && request.path == new_account_team_path return true if request.post? && request.path == account_teams_path false end |
#adding_user_details? ⇒ Boolean
35 36 37 |
# File 'app/controllers/concerns/account/controllers/base.rb', line 35 def adding_user_details? is_a?(Account::Onboarding::UserDetailsController) end |
#adding_user_email? ⇒ Boolean
31 32 33 |
# File 'app/controllers/concerns/account/controllers/base.rb', line 31 def adding_user_email? is_a?(Account::Onboarding::UserEmailController) end |
#ensure_onboarding_is_complete ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'app/controllers/concerns/account/controllers/base.rb', line 64 def ensure_onboarding_is_complete # This is temporary, but if we've gotten this far and `@team` is loaded, we need to ensure current_team is # updated for the checks below. This entire concept of `current_team` is going away soon. current_user.update(current_team: @team) if @team&.persisted? # since the onboarding controllers are child classes of this class, # we actually have to check to make sure we're not currently on that # step otherwise we'll end up in an endless redirection loop. if current_user.email_is_oauth_placeholder? if adding_user_email? return true else redirect_to edit_account_onboarding_user_email_path(current_user) return false end end # some team-related onboarding steps need to be skipped if we're in the process # of creating a new team. unless adding_team? || accepting_invitation? # USER ONBOARDING STUFF # first we make sure the user is properly onboarded. unless current_team.present? # don't force the user to create a team if they've already got one. if current_user.teams.any? current_user.update(current_team: current_user.teams.first) else redirect_to new_account_team_path return false end end # TEAM ONBOARDING STUFF. # then make sure the team is properly onboarded. # since the onboarding controllers are child classes of this class, # we actually have to check to make sure we're not currently on that # step otherwise we'll end up in an endless redirection loop. unless current_user.details_provided? if adding_user_details? return true else redirect_to edit_account_onboarding_user_detail_path(current_user) return false end end if billing_enabled? enforce_billing_requirements # See `app/controllers/concerns/billing_support.rb` for details. end end true end |
#ensure_onboarding_is_complete_and_set_next_step ⇒ Object
58 59 60 61 62 |
# File 'app/controllers/concerns/account/controllers/base.rb', line 58 def ensure_onboarding_is_complete_and_set_next_step unless ensure_onboarding_is_complete session[:after_onboarding_url] ||= request.url end end |
#managing_account? ⇒ Boolean
50 51 52 |
# File 'app/controllers/concerns/account/controllers/base.rb', line 50 def managing_account? is_a?(Account::UsersController) || self.class.module_parents.include?(Oauth) end |
#set_last_seen_at ⇒ Object
122 123 124 |
# File 'app/controllers/concerns/account/controllers/base.rb', line 122 def set_last_seen_at current_user.update_attribute(:last_seen_at, Time.current) end |
#switching_teams? ⇒ Boolean
45 46 47 48 |
# File 'app/controllers/concerns/account/controllers/base.rb', line 45 def switching_teams? return true if request.get? && request.path == account_teams_path false end |