2011-05-03 61 views
1

我試圖使用openid-selector-1.3.zip中的openid選擇器的原型版本,從Google Code 2011下載-May-03,with django-openid-auth在禁用谷歌和雅虎登錄按鈕的openid-selector(prototype.js版本)中的變通辦法缺陷

我已經關閉了JavaScript代碼中的演示模式。

該組合適用於launchpad.net openid,但不適用於Google或Yahoo。

當我點擊Google或Yahoo時,沒有任何反應!谷歌或雅虎的按鈕渲染爲沉沒。而已。當單擊Google或Yahoo按鈕時,django devserver也不會顯示POST表單。

當按下AOL時,文本框和提交按鈕被添加到表單中,但按下Google或Yahoo時不會發生這種情況......沒有額外的字段並且沒有登錄/提交按鈕。

我懷疑javascript錯誤或命名或id元素的問題。我的希望是,之前完成此操作的人可以很快看到問題,看看如何在下面的模板中設置表單。

測試的瀏覽器是Firefox 3.6.16(linux)和google chrome(linux)。他們似乎功能比較,都將登錄launchid的啓動板,但除了沉沒的標識符按鈕時,谷歌或雅虎點擊時什麼都不做。

這裏是django dev web服務器日誌,顯示所有靜態部分正在加載。這些代碼僅從code.google.com上的openid-selector發行版複製而來,僅做了一些小改動(關閉demo,設置圖像目錄)。這是爲了表明正確的片被輸送(當然,這也可以被緩存,因此缺席不會是決定性的...)

[03/May/2011 04:58:53] "GET/HTTP/1.1" 200 115 
[03/May/2011 04:58:56] "GET /openid/login HTTP/1.1" 301 0 
[03/May/2011 04:58:56] "GET /openid/login/ HTTP/1.1" 200 2182 
[03/May/2011 04:58:56] "GET /static/css/openid.css HTTP/1.1" 200 1007 
[03/May/2011 04:58:56] "GET /static/js/prototype.js HTTP/1.1" 200 162353 
[03/May/2011 04:58:56] "GET /static/js/openid-prototype.js HTTP/1.1" 200 5931 
[03/May/2011 04:58:56] "GET /static/js/openid-en.js HTTP/1.1" 200 2302 
[03/May/2011 04:58:56] "GET /static/images/openid-providers-en.png HTTP/1.1" 200 15894 

Django的OpenID的身份驗證只是提供了一個文本輸入/提交按鈕形式爲例。 但是它支持login.html的模板,所以在項目/模板/ OpenID的/ login.html的我有這個模板,正在呈現:

<?xml version="1.0" encoding="utf-8"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
     <title>Please Login</title> 
     <!-- Simple OpenID Selector --> 
     <link type="text/css" rel="stylesheet" href="/static/css/openid.css" /> 
     <script type="text/javascript" src="/static/js/prototype.js"></script> 
     <script type="text/javascript" src="/static/js/openid-prototype.js"></script> 
     <script type="text/javascript" src="/static/js/openid-en.js"></script> 
     <script type="text/javascript"> 
       document.observe('dom:loaded', function() { 
         openid.init('openid_identifier'); 
       }); 
     </script> 
     <!-- /Simple OpenID Selector --> 
     <style type="text/css"> 
       /* Basic page formatting */ 
       body { 
         font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 
       } 
     </style> 
</head> 

<body> 
     <h2>Please Select Your Provider for Login</h2> 
     <p>Select your identity provider from the list below. You will be sent there to log in and returned here as an identified user. There are no registration forms for this website or extra passwords to remember. </p> 
{% if form.errors %} 
<p class="errors">Please correct errors below:<br /> 
    {% if form.openid_identifier.errors %} 
    <span class="error">{{ form.openid_identifier.errors|join:", " }}</span> 
    {% endif %} 
    {% if form.next.errors %} 
    <span class="error">{{ form.next.errors|join:", " }}</span> 
    {% endif %} 
</p> 
{% endif %} 
     <br/> 
     <!-- Simple OpenID Selector --> 
     <form action="{{ action }}" name="fopenid" method="post" id="openid_form"> 
      {% csrf_token %} 
       <input type="hidden" name="action" value="verify" /> 
       <fieldset> 
         <legend>Sign-in or Create New Account</legend> 
         <div id="openid_choice"> 
           <p>Please click your account provider:</p> 
           <div id="openid_btns"></div> 
         </div> 
         <div id="openid_input_area"> 
           <input id="openid_identifier" name="openid_identifier" type="text" maxlength="255" value="http://" /> 
           <input id="openid_submit" type="submit" name="bsignin" value="Sign-In" /> 
         </div> 
         <noscript> 
         <p>You need javascript and cookies enabled and an OpenID to use this site. You are using a browser that does not support javascript or has javascript turned off.</p> 
         </noscript> 
       </fieldset> 
     </form> 
     <!-- /Simple OpenID Selector --> 
</body> 
</html> 

任何想法,問題可能是什麼?我認爲這可能涉及表單元素的命名,但我認爲我保留了原始ID。我確實更改了文本字段的表單名稱。

這似乎應該是一個解決的問題,以便我可以簡單地下載一個爲django定製的openid-selector的版本。但我找不到一個。有沒有更好的方式來進行這種整合?

回答

0

我能夠通過改變表單提交處理只是有點糾正OpenID的prototype.js中的谷歌/雅虎按鈕閒置的問題,具體如下:

步驟1:在的init(),OpenID的原型的.js大約47行,更改

$('openid_form').submit=this.submit

$('openid_form').onsubmit=this.submit

[步驟1中的先前設置似乎在單步執行時會引起奇怪的行爲。然而,函數this.submit === openid.submit現在只有在提交按鈕點擊時纔會被調用。要保留原始接口不添加一個按鈕,我改變爲簡單端點調用在STEP兩種功能2]

步驟2中的登入程序:在登入(),OpenID的prototype.js中大約95行,更改

if (!onload) {$('openid_form').submit();}

if (!onload) {if (this.submit()){$('openid_form').submit();}}}

使這兩個變化後,它的工作。我可以點擊谷歌或雅虎和OpenID的形式將被髮布到Django的OpenID的身份驗證的形式處理視圖

+0

如果有人有更好的答案,我會再尋找了幾天......接受我自己之前回答。 – Paul 2011-05-04 05:20:29

+0

這些編輯由andriy.gerasika,誰維護OpenID的選擇接受。見http://code.google.com/p/openid-selector/issues/detail?id=37&can=1 – Paul 2011-05-05 05:08:48