Class: Recruiter::OmniauthCallbacksController

Inherits:
Devise::OmniauthCallbacksController
  • Object
show all
Defined in:
app/controllers/recruiter/omniauth_callbacks_controller.rb

Instance Method Summary collapse

Instance Method Details

#facebookObject



8
9
10
# File 'app/controllers/recruiter/omniauth_callbacks_controller.rb', line 8

def facebook
  (Oauth::Facebook)
end

#githubObject



16
17
18
# File 'app/controllers/recruiter/omniauth_callbacks_controller.rb', line 16

def github
  (Oauth::Github)
end

#google_oauth2Object



12
13
14
# File 'app/controllers/recruiter/omniauth_callbacks_controller.rb', line 12

def google_oauth2
  (Oauth::Google)
end

#login_message(user) ⇒ Object



31
32
33
34
# File 'app/controllers/recruiter/omniauth_callbacks_controller.rb', line 31

def (user)
  key = user.new_record? ? 'account_created' : 'login_succeed'
  I18n.t("recruiter.messages.#{key}")
end

#login_with(klass) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/recruiter/omniauth_callbacks_controller.rb', line 20

def (klass)
  env          = request.env["omniauth.auth"]
  origin       = request.env["omniauth.origin"]
  user         = klass.find_or_build_user(env)
  redirect_url = redirect_url_for(user, origin)
  message      = (user)
  user.save!(validate: false)
  (user, event: :authentication)
  redirect_to redirect_url, notice: message, only_path: true
end

#new_session_path(scope) ⇒ Object

For handling errors



4
5
6
# File 'app/controllers/recruiter/omniauth_callbacks_controller.rb', line 4

def new_session_path(scope)
  new_user_session_path
end

#redirect_url_for(user, origin = nil) ⇒ Object



36
37
38
# File 'app/controllers/recruiter/omniauth_callbacks_controller.rb', line 36

def redirect_url_for(user, origin = nil)
  origin || root_url
end

#relative_path(url) ⇒ Object



40
41
42
43
# File 'app/controllers/recruiter/omniauth_callbacks_controller.rb', line 40

def relative_path(url)
  matches = url.match(/^http(s)?:\/\/[^\/]+(.*)/)
  matches ? matches[2] : url
end