Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
forgotpwd
Commits
e23ff1f4ef5e
Commit
02b2f3cb
authored
May 20, 2011
by
Sylvain Thénault
Browse files
fix some deprecation warnings and cleanup
parent
d36697f86f99
Changes
1
Hide whitespace changes
Inline
Side-by-side
views.py
View file @
e23ff1f4
...
...
@@ -13,12 +13,14 @@ from datetime import datetime, timedelta
from
yams
import
ValidationError
from
logilab.mtconverter
import
xml_escape
from
logilab.common.decorators
import
monkeypatch
from
cubicweb.view
import
StartupView
from
cubicweb.crypto
import
encrypt
,
decrypt
from
cubicweb.web
import
(
Redirect
,
controller
,
form
,
captcha
,
formwidgets
as
wdg
,
formfields
as
ff
)
from
cubicweb.web.views
import
forms
,
urlrewrite
,
basetemplates
from
cubicweb.server.repository
import
Repository
_
=
unicode
...
...
@@ -58,7 +60,7 @@ class ForgottenPasswordFormView(form.FormViewMixIn, StartupView):
def
call
(
self
):
form
=
self
.
_cw
.
vreg
[
'forms'
].
select
(
'forgottenpassword'
,
self
.
_cw
)
self
.
w
(
u
'<p>%s</p>'
%
self
.
_cw
.
_
(
u
'Forgot your password ?'
))
self
.
w
(
form
.
render
(
)
)
form
.
render
(
w
=
self
.
w
)
class
ForgottenPasswordSendMailController
(
controller
.
Controller
):
__regid__
=
'forgottenpassword_sendmail'
...
...
@@ -88,7 +90,7 @@ class ForgottenPasswordSendMailController(controller.Controller):
if
field
.
required
:
errors
[
field
.
name
]
=
self
.
_cw
.
_
(
'required attribute'
)
data
[
field
.
name
]
=
value
captcha
=
self
.
_cw
.
get_
session
_
data
(
'captcha'
,
None
,
pop
=
True
)
captcha
=
self
.
_cw
.
session
.
data
.
pop
(
'captcha'
,
None
)
if
captcha
is
None
:
errors
[
None
]
=
self
.
_cw
.
_
(
'unable to check captcha, please try again'
)
elif
data
[
'captcha'
].
lower
()
!=
captcha
.
lower
():
...
...
@@ -136,7 +138,7 @@ class ForgottenPasswordRequestView(form.FormViewMixIn, StartupView):
form
.
add_hidden
(
'use_email'
,
key
[
'use_email'
])
form
.
add_hidden
(
'revocation_id'
,
key
[
'revocation_id'
])
self
.
w
(
u
'<p>%s</p>'
%
self
.
_cw
.
_
(
u
'Update your password:'
))
self
.
w
(
form
.
render
(
)
)
form
.
render
(
w
=
self
.
w
)
class
ForgottenPasswordRequestConfirm
(
controller
.
Controller
):
...
...
@@ -176,9 +178,6 @@ class PasswordResetView(StartupView):
# Monkey Patching
# ---------------
from
cubicweb.server.repository
import
Repository
from
logilab.common.decorators
import
monkeypatch
from
cubicweb.mail
import
format_mail
@
monkeypatch
(
Repository
)
def
forgotpwd_send_email
(
self
,
data
):
...
...
@@ -211,8 +210,11 @@ def forgotpwd_send_email(self, data):
def
forgotpwd_change_passwd
(
self
,
data
):
session
=
self
.
internal_session
()
try
:
rset
=
session
.
execute
(
'Any F, U WHERE U is CWUser, U primary_email E, E address %(email)s, EXISTS(U has_fpasswd F, F revocation_id %(revid)s)'
,
{
'email'
:
data
[
'use_email'
],
'revid'
:
data
[
'revocation_id'
]})
rset
=
session
.
execute
(
'Any F, U WHERE U is CWUser, U primary_email E, '
'E address %(email)s, EXISTS(U has_fpasswd F, '
'F revocation_id %(revid)s)'
,
{
'email'
:
data
[
'use_email'
],
'revid'
:
data
[
'revocation_id'
]})
if
rset
:
forgotpwd
=
rset
.
get_entity
(
0
,
0
)
revocation_date
=
forgotpwd
.
revocation_date
...
...
@@ -223,7 +225,7 @@ def forgotpwd_change_passwd(self, data):
session
.
execute
(
'DELETE Fpasswd F WHERE F eid %(feid)s'
,
{
'feid'
:
forgotpwd
.
eid
})
session
.
commit
()
msg
=
session
.
_
(
u
'Your password has been changed
!
'
)
msg
=
session
.
_
(
u
'Your password has been changed
.
'
)
else
:
msg
=
session
.
_
(
u
'That link has either expired or is not valid.'
)
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment