0

我的 web2py 应用程序有一个有效的登录表单。

我不知道我改变了什么,但是在执行登录后,应用程序返回给我无效的函数默认/用户信息。

我正在使用 auth.settings.controller="user" 被重定向到正确的控制器。现在它不起作用。

应用程序应该返回到它来自的页面。仅限登录用户

解决这个问题后,我正在为自己安装一个 SVN,但在那之前。我真的不知道该怎么办

我正在使用 auth.navbar()

我的身份验证是 {{='auth' in globals() 和 auth.navbar(separators=(' ',' | ',''))}}

我的用户控制器 user.py 是

def user(): form = auth() return dict(form=form)

我的 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/' + database, migrate=True) from gluon.tools import Mail 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=['vid.ogris@algit.si'],
      subject='web2py registration',
      # If reply_to is omitted, then mail.settings.sender is used
      reply_to='us@example.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='xxx@gmail.com'
mail.settings.login='xxx@gmail.com: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')
4

2 回答 2

1

改变auth.settings.controller不起作用(这本书需要更新)。相反,您必须这样做:

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

此外,而不是:

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

你应该做:

URL('school','index', vars=dict(schools=database))
于 2012-09-05T11:28:25.633 回答
1

Sometimes comments in html are not only comments :) I removed a line containing auth.register(), even though I though it was commented, and now it works

于 2012-09-06T07:26:51.513 回答