Module: Insque

Defined in:
lib/devise_yauth_token/insque.rb

Class Method Summary collapse

Class Method Details

.yauth_account_create(msg) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/devise_yauth_token/insque.rb', line 34

def self. msg 
  unless Account.where(:yauth_account_id => msg['params']['id']).exists?
     = Account.new
    .yauth_host = msg['params']['host']
    .code = msg['params']['code']
    .name = msg['params']['name']
    . = msg['params']['id']
    .save! :validate => false
  end
end

.yauth_account_update(msg) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/devise_yauth_token/insque.rb', line 45

def self. msg
   = Account.where(:yauth_account_id => msg['params']['id']).first
  .yauth_host = msg['params']['host']
  .code = msg['params']['code']
  .name = msg['params']['name']
  .save! :validate => false
end

.yauth_user_create(msg) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/devise_yauth_token/insque.rb', line 8

def self.yauth_user_create msg
  unless User.where(:yauth_user_id => msg['params']['id']).exists?
    user = User.new
    user.email = msg['params']['email']
    user.omniauth_name = msg['params']['omniauth_name']
    user.yauth_user_id = msg['params']['id']
    user. = msg['params']['account_id']
    user.admin = msg['params']['admin']
    user. = Account.where(:yauth_account_id => user.).first.id
    user.save! :validate => false
  end
end

.yauth_user_destroy(msg) ⇒ Object



29
30
31
32
# File 'lib/devise_yauth_token/insque.rb', line 29

def self.yauth_user_destroy msg 
  user = User.where(:yauth_user_id => msg['params']['id']).first
  user.destroy
end

.yauth_user_sign_out(msg) ⇒ Object



2
3
4
5
6
# File 'lib/devise_yauth_token/insque.rb', line 2

def self.yauth_user_sign_out msg
  users = User.where(:yauth_user_id => msg['params']['id']) if msg['params']['id']
  users = User.where(:yauth_account_id => msg['params']['account_id']) if msg['params']['account_id']
  users.update_all :need_sign_out => true
end

.yauth_user_update(msg) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/devise_yauth_token/insque.rb', line 21

def self.yauth_user_update msg
  user = User.where(:yauth_user_id => msg['params']['id']).first
  user.email = msg['params']['email']
  user.omniauth_name = msg['params']['omniauth_name']
  user.admin = msg['params']['admin']
  user.save! :validate => false
end