asciinema.org/app/controllers/sessions_controller.rb

42 lines
889 B
Ruby
Raw Normal View History

class SessionsController < ApplicationController
before_filter :load_omniauth_auth, :only => :create
def new; end
def create
@user = request.env['asciiio.user']
if @user.persisted? || @user.save
2012-03-05 23:25:21 +00:00
self.current_user = @user
2012-07-25 18:24:20 +00:00
redirect_back_or_to root_url, :notice => "Logged in!"
else
store_sensitive_user_data_in_session
render 'users/new', :status => 422
2012-03-05 23:25:21 +00:00
end
end
def destroy
self.current_user = nil
2012-07-25 18:24:20 +00:00
redirect_to root_url, :notice => "Logged out!"
end
def failure
2013-05-27 21:44:12 +00:00
redirect_to root_url, :alert => "Authentication failed. Maybe try again?"
end
private
def load_omniauth_auth
@auth = request.env["omniauth.auth"]
end
2012-03-10 13:58:10 +00:00
def store_sensitive_user_data_in_session
2012-04-09 12:42:22 +00:00
session[:new_user] = {
:provider => @user.provider,
:uid => @user.uid,
:avatar_url => @user.avatar_url
}
2012-03-10 13:58:10 +00:00
end
end