Module: AuthClient::User

Extended by:
ActiveSupport::Concern
Included in:
User
Defined in:
lib/auth_client/user.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#activity_notifyObject



27
28
29
30
31
# File 'lib/auth_client/user.rb', line 27

def activity_notify
  check_app_name

  RedisUserConnector.set id, "#{app_name}_last_activity", Time.zone.now.to_i
end

#after_signed_inObject



47
48
49
# File 'lib/auth_client/user.rb', line 47

def after_signed_in
  info_notify
end

#app_nameObject



20
21
# File 'lib/auth_client/user.rb', line 20

def app_name
end

#check_app_nameObject



23
24
25
# File 'lib/auth_client/user.rb', line 23

def check_app_name
  raise 'User#app_name should not be blank' if app_name.blank?
end

#fullnameObject



16
17
18
# File 'lib/auth_client/user.rb', line 16

def fullname
  to_s
end

#info_hashObject



39
40
41
# File 'lib/auth_client/user.rb', line 39

def info_hash
  { :permissions => permissions_info, :url => "https://#{app_name}.tusur.ru/" }
end

#info_notifyObject



33
34
35
36
37
# File 'lib/auth_client/user.rb', line 33

def info_notify
  check_app_name

  RedisUserConnector.set id, "#{app_name}_info", info_hash.to_json
end

#last_activity_atObject



51
52
53
54
55
56
57
# File 'lib/auth_client/user.rb', line 51

def last_activity_at
  return nil if app_name.blank?

  seconds = instance_variable_get("@#{app_name}_last_activity").to_i

  Time.at(seconds)
end

#permissions_infoObject



43
44
45
# File 'lib/auth_client/user.rb', line 43

def permissions_info
  permissions.map { |p| { :role => p.role, :info => p.context.try(:to_s) }}
end

#to_sObject



12
13
14
# File 'lib/auth_client/user.rb', line 12

def to_s
  [surname, name, patronymic].compact.join(' ')
end