summaryrefslogtreecommitdiff
path: root/app/controllers/sessions_controller.rb
blob: ff06f0272acbecde23e01143466f530b40fecba9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class SessionController < ApplicationController
  def new
    # This route is catched by the Omniauth Middleware and is invisible to rake routes
    redirect_to '/auth/github'
  end

  def create
    user = User::Authenticable.authenticate(authorize_params)
    session[:uid] = user.uid
    redirect_to root_path
  end

  def destroy
    session.delete(:uid)
    redirect_to root_path
  end

  private

  def authorize_params
    request.env.fetch('omniauth.auth')
  end
end