Class: Pixnet::SSO::App

Inherits:
Object
  • Object
show all
Defined in:
lib/pixnet-sso/app.rb

Instance Method Summary collapse

Constructor Details

#initializeApp

Returns a new instance of App.



8
9
10
# File 'lib/pixnet-sso/app.rb', line 8

def initialize
  @error_message = ""
end

Instance Method Details

#decode_process(token) ⇒ Object



12
13
14
15
16
# File 'lib/pixnet-sso/app.rb', line 12

def decode_process(token)
  signature = crate_signature(token)
  message = parse_json_request(token, signature)
  return check_status(message)
end

#get_openid_user(info) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/pixnet-sso/app.rb', line 31

def get_openid_user(info)
  return false if info['msg']['openid'].blank?
  openid_user = Pixnet::SSO::Config.openid_klass.find_or_initialize_by_openid(info['msg']['openid'])
  if openid_user.new_record?
    openid_user.provider = info['msg']['openid_type']
    openid_user.extra = info['msg']['openid_data'].to_json
    openid_user.save
  end
  return openid_user
end

#get_user(user_name) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pixnet-sso/app.rb', line 18

def get_user(user_name)
  user = Pixnet::SSO::Config.user_klass.(user_name)
  if user_name.blank?
    return false
  else
    if user.new_record?
      user.save(:validate => false)
    end

    return user
  end
end

#show_errorObject



42
43
44
# File 'lib/pixnet-sso/app.rb', line 42

def show_error
  return @error_message
end