Class: Stenographer::AuthenticationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/stenographer/authentications_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/stenographer/authentications_controller.rb', line 9

def create
  auth_hash = request.env['omniauth.auth']
  @hash = auth_hash

  if auth_hash.try(:provider).present?
    Authentication.find_or_create_by(provider: auth_hash.provider) do |authentication|
      authentication.uid = auth_hash.uid
      authentication.credentials = auth_hash.credentials.present? ? auth_hash.credentials.to_json : nil
      authentication.source = auth_hash.to_json
    end

    flash[:notice] = 'Successfully created the Authentication'
    redirect_to admin_authentications_path
  else
    flash[:alert] = 'Did not receive oAuth provider info'
    redirect_back(fallback_location: root_path)
  end
end

#failureObject



28
# File 'app/controllers/stenographer/authentications_controller.rb', line 28

def failure; end