Class: HeimdallAuth::SessionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/heimdall_auth/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
# File 'app/controllers/heimdall_auth/sessions_controller.rb', line 15

def create
  auth = request.env["omniauth.auth"]
  session[:access_token] = auth&.credentials&.token
  redirect_to( session[:last_url] || request.base_url, allow_other_host: true)
end

#destroyObject



21
22
23
24
25
# File 'app/controllers/heimdall_auth/sessions_controller.rb', line 21

def destroy
  last_url = session[:last_url]
  reset_session
  redirect_to("#{ENV['HEIMDALL_SERVER_URL']}/signout?redirect_to=#{last_url || request.base_url}", :notice => 'Signed out!', allow_other_host: true)
end

#failureObject



27
28
29
# File 'app/controllers/heimdall_auth/sessions_controller.rb', line 27

def failure
  redirect_to request.base_url, :alert => "Authentication error: #{params[:message].humanize}", allow_other_host: true
end

#login_buttonObject



31
32
# File 'app/controllers/heimdall_auth/sessions_controller.rb', line 31

def 
end

#newObject



4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/heimdall_auth/sessions_controller.rb', line 4

def new
  user_token = params[:user_token].presence
  heimdall_auth_url = auth_provider_url(provider: "heimdall")

  if user_token
    (user_token, heimdall_auth_url)
  else
    redirect_to heimdall_auth_url, allow_other_host: true
  end
end