Module: Pixnet::SSO::Helper

Defined in:
lib/pixnet-sso/helper.rb

Instance Method Summary collapse

Instance Method Details

#pixnet_login_urlObject



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

def 
  "http://www.pixnet.net/?done=#{url_encode(request.url)}"
end

#pixnet_logout_urlObject



12
13
14
# File 'lib/pixnet-sso/helper.rb', line 12

def pixnet_logout_url
  "http://panel.pixnet.cc/logout?done=#{url_encode(request.url)}"
end

#pixnet_sso2_scriptsObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pixnet-sso/helper.rb', line 42

def pixnet_sso2_scripts
  unique = Zlib.crc32(UUID.generate).to_s
  now = Time.now.to_i.to_s
  sig = Zlib.crc32("#{Pixnet::SSO::Config.sso_secret}#{unique}#{now}")
  html = <<MSG
  <script type="text/javascript" src="//checklogin.#{request.host}/login_name.php?key=#{Pixnet::SSO::Config.sso_key}&unique=#{unique}&timestamp=#{now}&sig=#{sig}"></script>
  <script type="text/javascript" src="//api.pixnet.cc/api/checklogin.php?js=1&unique=#{unique}&timestamp=#{now}&type=2"></script>
  <script src="http://s.pixfs.net/js/pixnet/checklogin.js?v=20110519" type="text/javascript"></script>
MSG
  return html.html_safe
end

#pixnet_sso_scriptsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pixnet-sso/helper.rb', line 16

def pixnet_sso_scripts
  now = Time.now.to_i.to_s
  unique = Zlib.crc32(UUID.generate).to_s
  user_name = current_user.blank? ? "" : current_user.
   = "#{user_name}.pixnet.net#{unique}#{now}"

  if Pixnet::SSO::Config.openid_enabled and current_openid_user
     = "#{}#{current_openid_user.openid}"
  end
  html = <<MSG
<script type="text/javascript">
  <!--
  var pix = pix || {};
  pix.apisite = 'api.pixnet.cc';
  pix.login_name = "#{Digest::MD5.hexdigest()}";
  pix.server_name = "#{URI::parse(request.host)}";
  pix.checklogin_version = 2;
  pix.checklogin_callback = '#{api_checklogin_path}';
  -->
</script>
<script src="//api.pixnet.cc/api/checklogin.php?js=1&amp;unique=#{unique}&amp;timestamp=#{now}&amp;type=2" type="text/javascript"></script>
<script src="http://s.pixfs.net/js/pixnet/checklogin.js?v=20110519" type="text/javascript"></script>
MSG
  return html.html_safe
end