Refactoring.

This commit is contained in:
Martin Edenhofer 2012-04-18 10:33:42 +02:00
parent 900fb35e5b
commit aba551df66

View file

@ -66,37 +66,31 @@ class SessionsController < ApplicationController
render :json => { }
end
def create_omniauth
# auth = request.env['rack.auth']
auth = request.env['omniauth.auth']
logger.info(auth.inspect)
if !auth
logger.info("AUTH IS NULL, SERVICE NOT LINKED TO ACCOUNT")
# logger.info()
# logger.info("PROVIDER: #{provider}, UID: #{uid}, EMAIL: #{email}")
# redirect to app
redirect_to '/app#'
end
logger.info(1111111)
# raise auth.to_yaml
unless @auth = Authorization.find_from_hash(auth)
# Create a new user or add an auth to existing user, depending on
# whether there is already a user signed in.
@auth = Authorization.create_from_hash(auth, current_user)
# Create a new user or add an auth to existing user, depending on
# whether there is already a user signed in.
authorization = nil
if current_user
authorization = Authorization.create_from_hash(auth, current_user)
else
authorization = Authorization.find_from_hash(auth)
end
# logger.info(2222222)
# logger.info(@auth)
# logger.info(@auth.inspect)
# logger.info(@auth.user)
# Log the authorizing user in.
# self.current_user = @auth.user
# user = @auth.user
# logger.info(333333333)
# exit
session[:user_id] = @auth.user.id
session[:user_id] = authorization.user.id
# redirect to app
redirect_to '/app#'
redirect_to '/app#'
end
private