2012-09-05 127 views
0

我有我的web2py應用程序的工作登錄表單。web2py post登錄重定向

我不知道我改變了什麼,但登錄後執行應用程序返回我的無效功能默認/用戶信息。

我正在使用auth.settings.controller =「user」重定向到正確的控制器。現在它不起作用。

應用程序應該回到它來自的頁面。只有登錄用戶

解決此問題後,我正在安裝自己的SVN,但在那之前。 我真的不知道是什麼

我ALO使用auth.navbar()做

我考慮到身份驗證是{{=在全局 '權威性'()和 auth.navbar(分隔符= ( ' '' |', ''))}}

我的用戶CONTROLER user.py是

DEF用戶(): 形式= AUTH() 返回字典(形式=形式)

和我的user.py模型是

if(request.controller =='user'or request.controller =='school'or request.controller =='timetable'and request.cookies.has_key('mycookie' ): response.generic_patterns = ['*'] if request.is_local else [] database = request.cookies ['mycookie']。value baza = DAL('postgres:// postgres:postgres @ localhost /' +數據庫遷移= TRUE) 從gluon.tools導入郵件 AUTH =驗證(巴扎)

auth.settings.logout_next=URL('school','index?school=' + database) 


auth.settings.registration_requires_approval = True 
#auth.settings.reset_password_requires_verification = True 
#auth.settings.login_after_registration = False 
auth.settings.register_onaccept=lambda form: mail.send(to=['[email protected]'], 
     subject='web2py registration', 
     # If reply_to is omitted, then mail.settings.sender is used 
     reply_to='[email protected]le.com', 
     message='Kreiral se je nov uporabnik, ki ga je potrebno potrditi') 

auth.settings.expiration = 3600 
auth.define_tables() 

mail=Mail() 
auth.settings.mailer=mail 
mail.settings.server='smtp.gmail.com:587' 
mail.settings.sender='[email protected]' 
mail.settings.login='[email protected]:xxx' 

#auth.settings.registration_requires_verification = True 

auth.messages.registration_pending = u'Registracija je v postopku odobritve. Ko bo vaš račun potrjen boste prejeli e-mail.' 
auth.messages.invalid_login = 'Nepravilno geslo' 
auth.messages.invalid_user = 'Uporabnik ne obstaja' 



auth.settings.controller="user" 



## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc. 
## register with janrain.com, write your domain:api_key in private/janrain.key 
from gluon.contrib.login_methods.rpx_account import use_janrain 
use_janrain(auth,filename='private/janrain.key') 
+0

你可以顯示你的Auth設置代碼以及你的用戶控制器代碼?當您進入登錄頁面時,查詢字符串中的_next參數是什麼? – Anthony

+0

如果我點擊取回密碼,我會收到一封錯誤地址的電子郵件。它試圖讓我在portalov_iurnik/default/user/reset_password/1346840165-f35f1af2-f1fb-45c1-afff-fb822c2cf35d它應該將我重定向到portalov_iurnik/user/user/reset_password/1346840165-f35f1af2-f1fb-45c1-afff-fb822c2cf35d 。它始終處於默認狀態。 如果我輸入網頁的URL,我應該把它重定向到/ portal_iurnik/default/user/etc – Yebach

回答

1

在HTML註釋有時不僅評論:)我刪除一包含auth.register(),即使我雖然它已被評論,現在它的作品

+1

如果你有類似於<! - {{= auth.register()}} - >'的語句,Python代碼仍然會由模板引擎運行。 HTML註釋用於評論HTML。要評論Python代碼,您必須使用Python註釋:'{{#= auth.register()}}'。這允許模板生成包含註釋的HTML。 – Anthony

1

更改auth.settings.controller不工作(這本書需要更新)。相反,你必須做的:

auth = Auth(baza, controller='user') 

此外,而不是:

URL('school','index?school=' + database) 

你應該做的:

URL('school','index', vars=dict(schools=database)) 
+0

好吧,有一點幫助(我沒有得到無效的函數錯誤),但爲什麼我點擊登錄後按鈕重定向到/ user/user/profile?取而代之的是我之前的觀點? – Yebach

+0

聽起來像你在某處調用'auth.register()'。如果您在用戶已經登錄後調用該函數,它將重定向到'auth.settings。logged_url',默認爲配置文件URL。在你的代碼中,首先在調用'auth.register()'之前檢查用戶是否已經登錄。 – Anthony