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
cd559ea6cc0a
Commit
4cb6a345
authored
May 16, 2019
by
Denis Laxalde
Browse files
Make code base compatible with python3
parent
fdd4ff0f95cc
Changes
6
Hide whitespace changes
Inline
Side-by-side
cubicweb_forgotpwd/__pkginfo__.py
View file @
cd559ea6
...
...
@@ -23,6 +23,7 @@ classifiers = [
__depends__
=
{
'cubicweb'
:
'>= 3.25.0'
,
'pycrypto'
:
None
,
'Pillow'
:
None
,
'six'
:
None
,
}
...
...
cubicweb_forgotpwd/hooks.py
View file @
cd559ea6
...
...
@@ -8,13 +8,13 @@ from datetime import datetime, timedelta
from
logilab.common.decorators
import
monkeypatch
from
yams
import
ValidationError
from
cubicweb
import
_
from
cubicweb.predicates
import
is_instance
from
cubicweb.crypto
import
encrypt
from
cubicweb.server
import
hook
from
cubicweb.server.repository
import
Repository
from
cubicweb.sobjects.notification
import
NotificationView
_
=
unicode
class
ServerStartupHook
(
hook
.
Hook
):
"""on startup, register a task to delete old revocation key"""
...
...
cubicweb_forgotpwd/sobjects.py
View file @
cd559ea6
...
...
@@ -2,12 +2,10 @@ import random
import
string
from
datetime
import
datetime
,
timedelta
from
cubicweb
import
ValidationError
from
cubicweb
import
_
,
ValidationError
from
cubicweb.predicates
import
match_kwargs
from
cubicweb.server
import
Service
_
=
unicode
class
ForgotPwdEmailService
(
Service
):
"""Generate a password reset request, store it in the database, and send
...
...
@@ -20,8 +18,8 @@ class ForgotPwdEmailService(Service):
cnx
=
self
.
_cw
repo
=
cnx
.
repo
revocation_limit
=
repo
.
config
[
'revocation-limit'
]
revocation_id
=
u
''
.
join
(
random
.
choice
(
string
.
letters
+
string
.
digits
)
for
x
in
x
range
(
10
))
revocation_id
=
u
''
.
join
(
random
.
choice
(
string
.
ascii_
letters
+
string
.
digits
)
for
x
in
range
(
10
))
revocation_date
=
datetime
.
now
()
+
timedelta
(
minutes
=
revocation_limit
)
existing_requests
=
cnx
.
execute
(
'Any F WHERE U primary_email E, E address %(e)s, U has_fpasswd F'
,
...
...
cubicweb_forgotpwd/views.py
View file @
cd559ea6
...
...
@@ -6,17 +6,19 @@
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
from
six
import
text_type
from
yams
import
ValidationError
from
logilab.mtconverter
import
xml_escape
from
cubicweb
import
_
from
cubicweb.view
import
StartupView
from
cubicweb.crypto
import
decrypt
from
cubicweb.web
import
(
Redirect
,
controller
,
form
,
captcha
,
formwidgets
as
wdg
,
formfields
as
ff
)
from
cubicweb.web.views
import
forms
,
urlrewrite
,
basetemplates
_
=
unicode
# Login form
# ----------
...
...
@@ -70,8 +72,8 @@ class ForgottenPasswordSendMailController(controller.Controller):
cnx
.
commit
()
except
ValidationError
:
raise
except
Exception
,
exc
:
msg
=
unicod
e
(
exc
)
except
Exception
as
exc
:
msg
=
text_typ
e
(
exc
)
else
:
msg
=
self
.
_cw
.
_
(
u
'An email has been sent, follow instructions in there to change your password.'
)
raise
Redirect
(
self
.
_cw
.
build_url
(
'pwdsent'
,
__message
=
msg
))
...
...
debian/control
View file @
cd559ea6
...
...
@@ -16,6 +16,7 @@ Depends:
python-cubicweb (>= 3.25),
python-crypto,
python-imaging,
python-six,
${python:Depends},
${misc:Depends},
Description: password recovery component for the CubicWeb framework
...
...
test/unittest_notifications.py
View file @
cd559ea6
...
...
@@ -10,7 +10,7 @@ class ForgotTC(CubicWebTC):
def
setup_database
(
self
):
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
for
index
in
x
range
(
4
):
for
index
in
range
(
4
):
user
=
self
.
create_user
(
cnx
,
u
'test_user%s'
%
index
)
cnx
.
create_entity
(
'EmailAddress'
,
address
=
u
'test_user%s@logilab.fr'
%
index
,
...
...
Write
Preview
Supports
Markdown
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