Module: Fera::Apps::Controllers::Auth
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/fera/apps/concerns/controllers/auth.rb
Instance Method Summary collapse
-
#after_fera_callback ⇒ Object
You should override this in your own controller.
-
#callback ⇒ Object
GET /auth/fera/callback.
-
#check ⇒ Object
GET /fera/auth/check GET /fera/auth/check.json.
- #disconnect ⇒ Object
-
#load ⇒ Object
Override this to send them someone else.
-
#success ⇒ Object
GET /fera/auth/success.
- #test ⇒ Object
Instance Method Details
#after_fera_callback ⇒ Object
You should override this in your own controller.
26 27 28 29 |
# File 'lib/fera/apps/concerns/controllers/auth.rb', line 26 def after_fera_callback ::Rails.logger.warn("#after_fera_callback not implemented in your controller, so the default action was to redirect to the root_path") redirect_to root_path end |
#callback ⇒ Object
GET /auth/fera/callback
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fera/apps/concerns/controllers/auth.rb', line 13 def callback if @store.try(:fera_id) != params[:store_id] @store = ::Store.find_or_initialize_by(fera_id: params[:store_id]) # Fera::Store also exists so make sure to include `::` prefix to reference right class end @store.install_fera!(request) set_current_store(@store) after_fera_callback end |
#check ⇒ Object
GET /fera/auth/check GET /fera/auth/check.json
69 70 71 72 73 74 75 76 |
# File 'lib/fera/apps/concerns/controllers/auth.rb', line 69 def check respond_to do |format| format.json { render json: status_result, status: status_result[:status] } format.html do redirect_to root_path, (status_result[:status] == :connected ? :notice : :alert) => status_result[:message], status: status_result[:status] end end end |
#disconnect ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/fera/apps/concerns/controllers/auth.rb', line 40 def disconnect if @store.present? @store.destroy! redirect_to root_path, notice: "Disconnected app from Fera successfully." else redirect_to root_path, flash: { error: "Not connected to Fera, so disconnecting did nothing." } end end |
#load ⇒ Object
Override this to send them someone else
34 35 36 |
# File 'lib/fera/apps/concerns/controllers/auth.rb', line 34 def load redirect_to root_path end |
#success ⇒ Object
GET /fera/auth/success
62 63 64 |
# File 'lib/fera/apps/concerns/controllers/auth.rb', line 62 def success redirect_to fera_app_relay_url(fera_app_connect_success_msg) end |
#test ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/fera/apps/concerns/controllers/auth.rb', line 51 def test respond_to do |format| format.json { render json: status_result, status: status_result[:status] } format.html do redirect_to fera_app_relay_url(status_result[:status], status_result[:message]) end end end |