Class: GithubOnRails::SessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/github_on_rails/sessions_controller.rb

Instance Method Summary collapse

Methods included from ControllerExtensions

#current_user

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/github_on_rails/sessions_controller.rb', line 13

def create
  auth = request.env['omniauth.auth']
  user = User.where(provider: auth['provider'],
                    uid: auth['uid'].to_s).first || User.create_with_omniauth(auth)

  reset_session
  session[:user_id] = user.id
  session[:auth_token] = auth.credentials['token']
  redirect_to main_app.root_url, notice: 'Signed in!'
end

#destroyObject



24
25
26
27
# File 'app/controllers/github_on_rails/sessions_controller.rb', line 24

def destroy
  reset_session
  redirect_to main_app.root_url, notice: 'Signed out!'
end

#failureObject



29
30
31
# File 'app/controllers/github_on_rails/sessions_controller.rb', line 29

def failure
  redirect_to main_app.root_url, alert: "Authentication error: #{params['error'].try(:humanize)}"
end

#newObject



6
7
8
# File 'app/controllers/github_on_rails/sessions_controller.rb', line 6

def new
  redirect_to '/auth/github'
end

#showObject



10
11
# File 'app/controllers/github_on_rails/sessions_controller.rb', line 10

def show
end