Class: SessionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/sessions_controller.rb', line 21

def create
  auth_hash = request.env['omniauth.auth']
  user      = User.find_by_auth_hash(auth_hash) || User.new

  user.assign_from_auth_hash(auth_hash)

  flash[:notice] = nil
  session[:user_id] = user.id

  user.update_repo_permissions_async

  redirect_to(root_path) && return unless 
  redirect_to 
end

#destroyObject


36
37
38
39
# File 'app/controllers/sessions_controller.rb', line 36

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

#enable_privateObject


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

def enable_private
  session[:pre_login_destination] = repositories_path
  redirect_to "/auth/github_private"
end

#enable_publicObject


11
12
13
14
# File 'app/controllers/sessions_controller.rb', line 11

def enable_public
  session[:pre_login_destination] = repositories_path
  redirect_to "/auth/github_public"
end

#failureObject


41
42
43
# File 'app/controllers/sessions_controller.rb', line 41

def failure
  redirect_to root_path, notice: params[:message]
end

#newObject


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

def new
  session[:pre_login_destination] = params[:return_to] if params[:return_to].present?
  redirect_to "/auth/github"
end