lib/ditty/helpers/authentication.rb in ditty-0.3.1 vs lib/ditty/helpers/authentication.rb in ditty-0.3.2

- old
+ new

@@ -2,19 +2,23 @@ module Ditty module Helpers module Authentication def current_user - if env['rack.session'].nil? || env['rack.session']['user_id'].nil? - self.current_user = anonymous_user - end + user_id = current_user_id + self.current_user = anonymous_user if user_id.nil? @users ||= Hash.new { |h, k| h[k] = User[k] } - @users[env['rack.session']['user_id']] + @users[user_id] end def current_user=(user) env['rack.session'] = {} if env['rack.session'].nil? env['rack.session']['user_id'] = user.id if user + end + + def current_user_id + return env['omniauth.auth'].uid if env['omniauth.auth'] + env['rack.session']['user_id'] if env['rack.session'] end def authenticate authenticated? end