@@ -20,6 +20,16 @@ class ApplicationController < ActionController::Base
raise PermissionException, 'Only moderators can access this area' unless current_user.is_a?(User) and current_user.can_moderate?
end
+ def get_ident
+ if current_user.nil? or current_user.is_guest?
+ ident = request.env['REMOTE_ADDR']
+ ident = 'Unknown' if ident.nil?
+ else
+ ident = current_user.username
+ end
+ ident
+ end
+
private
def can_read_board?
@@ -34,8 +44,7 @@ class ApplicationController < ActionController::Base
def online_check
if current_user.is_guest?
- ident = request.env['REMOTE_ADDR']
- ident = 'Unknown' if ident.nil?
+ ident = get_ident
ticket = Online.find :first, :conditions => ['ident = ?', ident]
if ticket.nil?
ticket = Online.new
@@ -45,7 +54,7 @@ class ApplicationController < ActionController::Base
ticket = Online.find :first, :conditions => ['user_id = ?',current_user.id]
if ticket.nil?
ticket = Online.new
- ticket.ident = current_user.username
+ ticket.ident = get_ident
ticket.user = current_user
end
ticket.idle = false