Locale switch, greetings page

This commit is contained in:
magnolia-fan
2011-09-17 14:20:07 +04:00
parent 95c0b9fc12
commit 67e79acf23
6 changed files with 31 additions and 4 deletions
+12
View File
@@ -2,6 +2,7 @@ require 'digest'
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
def authorized?
# secret_key = request.host == 'beathaven.org' ? 'sdgwSbl3nNE4ZxafuPrp' : 's5zyjb693z6uV4rbhEyc'
@@ -24,8 +25,19 @@ class ApplicationController < ActionController::Base
end
end
def set_locale
session = Session.find_by_key(request.cookies['_beathaven_session'][0..31])
unless session.nil?
I18n.locale = session.user.lang
end
end
def index
end
def greetings
render :partial => 'greetings'
end
end
+8 -2
View File
@@ -12,9 +12,15 @@ class UserController < ApplicationController
user.save
@res[:newbie] = true
end
cookie_key = request.cookies['_beathaven_session'][0..31]
session = Session.find_or_create_by_user_id(user.id)
session.key = Digest::SHA256.hexdigest(rand(99999999).to_s + user.id.to_s + rand(99999999).to_s)
session.save
if session.key != cookie_key
session.key = cookie_key
session.save
render :json => { 'ok_reload' => true }
return
end
@res[:user] = {
:id => user.id,