簡體   English   中英

禁用 Google 和 Yahoo 登錄按鈕的 openid-selector(prototype.js 版本)中的解決方法錯誤

[英]Workaround bug in openid-selector (prototype.js version) that disables Google and Yahoo login buttons

我正在嘗試使用 openid-selector-1.3.zip 中找到的 openid 選擇器的原型版本,從 Google Code 2011-May-03 下載,帶有 django-openid-auth

我在 javascript 代碼中關閉了演示模式。

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

當我點擊 Google 或 Yahoo 時,什么也沒有發生。 google 或 yahoo 的按鈕呈現為凹陷。 而已。 此外,django 開發服務器在單擊 Google 或 Yahoo 按鈕時從不顯示表單 POST。

當按下 AOL 時,會在表單中添加一個文本字段和一個提交按鈕……但是當按下 Google 或 Yahoo 時不會發生這種情況……沒有額外的字段,也沒有登錄/提交按鈕。

我懷疑 javascript 錯誤或命名或標識元素的問題。 我希望以前這樣做過的人可以通過查看下面模板中的表單設置方式快速看到問題。

測試的瀏覽器是 Firefox 3.6.16 (linux) 和 google chrome (linux)。 他們似乎與 function 相當,兩者都將登錄啟動板 openid,但除了在單擊 google 或 yahoo 時下沉標識符按鈕之外什么也不做。

這是 django 開發網絡服務器日志,顯示正在加載所有 static 片段。 這些是從 code.google.com 的 openid-selector 發行版復制而來的,只有幾個小改動(關閉演示,設置圖像目錄)。 這是為了表明正在交付正確的部分(當然,這些也可以被緩存,因此缺席不會是決定性的......)

[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-auth 僅提供文本輸入/提交按鈕表單作為示例。 但它支持 login.html 模板,所以在 project/templates/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 版本。 但我找不到一個。 關於此集成,go 是否有更好的方法?

通過稍微更改表單提交處理,我能夠更正 openid-prototype.js 中的 Google/Yahoo 按鈕不活動問題,如下所示:

第 1 步:在 init() 中,openid-prototype.js 大約第 47 行,更改

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

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

[STEP 1 中的先前設置似乎在單步時引起了奇怪的行為。 然而,function this.submit === openid.submit 現在只有在有提交按鈕可以點擊時才會被調用。 為了在不添加按鈕的情況下保留原始界面,我更改了簡單端點的登錄過程,以在步驟 2 中調用這兩個函數]

第 2 步:在 signin() 中,openid-prototype.js 大約第 95 行,更改

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

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

進行這兩項更改后,它起作用了。 我可以點擊 Google 或 Yahoo,openid 表單將被發布到 django-openid-auth 中的表單處理視圖

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM