Class: GithubOnRails::SessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- GithubOnRails::SessionsController
- Defined in:
- app/controllers/github_on_rails/sessions_controller.rb
Instance Method Summary collapse
Methods included from ControllerExtensions
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#failure ⇒ Object
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 |
#new ⇒ Object
6 7 8 |
# File 'app/controllers/github_on_rails/sessions_controller.rb', line 6 def new redirect_to '/auth/github' end |
#show ⇒ Object
10 11 |
# File 'app/controllers/github_on_rails/sessions_controller.rb', line 10 def show end |