refactor and organise current_user better

This commit is contained in:
Sam Saffron
2013-02-24 21:42:04 +11:00
parent ab97dc8fd6
commit b66db4153d
4 changed files with 39 additions and 23 deletions

View File

@ -111,15 +111,6 @@ class ApplicationController < ActionController::Base
@guardian ||= Guardian.new(current_user)
end
def log_on_user(user)
session[:current_user_id] = user.id
unless user.auth_token
user.auth_token = SecureRandom.hex(16)
user.save!
end
cookies.permanent[:_t] = { :value => user.auth_token, :httponly => true }
end
# This is odd, but it seems that in Rails `render json: obj` is about
# 20% slower than calling MultiJSON.dump ourselves. I'm not sure why
# Rails doesn't call MultiJson.dump when you pass it json: obj but