Locale switch, greetings page
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user