pyramid-fullauth 0.3.1__py2.7.egg → 0.5.0__py2.7.egg
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- EGG-INFO/PKG-INFO +48 -10
- EGG-INFO/SOURCES.txt +2 -0
- EGG-INFO/requires.txt +4 -6
- EGG-INFO/top_level.txt +1 -1
- pyramid_fullauth/__init__.py +3 -3
- pyramid_fullauth/__init__.pyc +0 -0
- pyramid_fullauth/auth.py +2 -1
- pyramid_fullauth/auth.pyc +0 -0
- pyramid_fullauth/compat.py +18 -0
- pyramid_fullauth/compat.pyc +0 -0
- pyramid_fullauth/events.py +24 -11
- pyramid_fullauth/events.pyc +0 -0
- pyramid_fullauth/exceptions.pyc +0 -0
- pyramid_fullauth/models/__init__.py +5 -4
- pyramid_fullauth/models/__init__.pyc +0 -0
- pyramid_fullauth/models/extensions/__init__.py +39 -0
- pyramid_fullauth/models/extensions/__init__.pyc +0 -0
- pyramid_fullauth/models/mixins/__init__.pyc +0 -0
- pyramid_fullauth/models/mixins/email.py +53 -6
- pyramid_fullauth/models/mixins/email.pyc +0 -0
- pyramid_fullauth/models/mixins/password.pyc +0 -0
- pyramid_fullauth/request.py +8 -7
- pyramid_fullauth/request.pyc +0 -0
- pyramid_fullauth/resources/helpers/social.mako +3 -3
- pyramid_fullauth/resources/locale/pyramid_fullauth.pot +23 -23
- pyramid_fullauth/routing/__init__.pyc +0 -0
- pyramid_fullauth/routing/predicates.pyc +0 -0
- pyramid_fullauth/tools.py +6 -3
- pyramid_fullauth/tools.pyc +0 -0
- pyramid_fullauth/views/__init__.pyc +0 -0
- pyramid_fullauth/views/basic/__init__.pyc +0 -0
- pyramid_fullauth/views/basic/activate.py +2 -2
- pyramid_fullauth/views/basic/activate.pyc +0 -0
- pyramid_fullauth/views/basic/forbidden.py +2 -3
- pyramid_fullauth/views/basic/forbidden.pyc +0 -0
- pyramid_fullauth/views/basic/login.py +10 -10
- pyramid_fullauth/views/basic/login.pyc +0 -0
- pyramid_fullauth/views/basic/logout.py +3 -3
- pyramid_fullauth/views/basic/logout.pyc +0 -0
- pyramid_fullauth/views/basic/profile/__init__.pyc +0 -0
- pyramid_fullauth/views/basic/profile/email.py +7 -6
- pyramid_fullauth/views/basic/profile/email.pyc +0 -0
- pyramid_fullauth/views/basic/profile/password.py +9 -8
- pyramid_fullauth/views/basic/profile/password.pyc +0 -0
- pyramid_fullauth/views/basic/register.py +9 -8
- pyramid_fullauth/views/basic/register.pyc +0 -0
- pyramid_fullauth/views/social.py +11 -8
- pyramid_fullauth/views/social.pyc +0 -0
- tests/__init__.pyc +0 -0
- tests/conftest.py +2 -1
- tests/conftest.pyc +0 -0
- tests/tools.py +1 -1
- tests/tools.pyc +0 -0
- tests/unit/test_default_settings.pyc +0 -0
- tests/unit/test_groupfinder.pyc +0 -0
- tests/unit/test_social_view.py +28 -26
- tests/unit/test_social_view.pyc +0 -0
- tests/unit/test_tools.pyc +0 -0
- tests/unit/test_user_active.pyc +0 -0
- tests/unit/test_user_admin.pyc +0 -0
- tests/unit/test_user_email.pyc +0 -0
- tests/unit/test_user_password.py +1 -1
- tests/unit/test_user_password.pyc +0 -0
- tests/unit/test_user_providers.pyc +0 -0
- tests/unit/test_user_repr.py +2 -2
- tests/unit/test_user_repr.pyc +0 -0
- tests/unit/test_validators.py +1 -1
- tests/unit/test_validators.pyc +0 -0
- tests/views/__init__.pyc +0 -0
- tests/views/conftest.py +5 -0
- tests/views/conftest.pyc +0 -0
- tests/views/test_activation.py +13 -6
- tests/views/test_activation.pyc +0 -0
- tests/views/test_email.py +3 -3
- tests/views/test_email.pyc +0 -0
- tests/views/test_events.py +36 -33
- tests/views/test_events.pyc +0 -0
- tests/views/test_login.py +25 -4
- tests/views/test_login.pyc +0 -0
- tests/views/test_login_social.py +97 -69
- tests/views/test_login_social.pyc +0 -0
- tests/views/test_logout.py +2 -2
- tests/views/test_logout.pyc +0 -0
- tests/views/test_register.py +9 -5
- tests/views/test_register.pyc +0 -0
- tests/views/test_reset.py +9 -4
- tests/views/test_reset.pyc +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Translations template for pyramid_fullauth.
|
|
2
|
-
# Copyright (C)
|
|
2
|
+
# Copyright (C) 2015 ORGANIZATION
|
|
3
3
|
# This file is distributed under the same license as the pyramid_fullauth
|
|
4
4
|
# project.
|
|
5
|
-
# FIRST AUTHOR <EMAIL@ADDRESS>,
|
|
5
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2015.
|
|
6
6
|
#
|
|
7
7
|
#, fuzzy
|
|
8
8
|
msgid ""
|
|
9
9
|
msgstr ""
|
|
10
|
-
"Project-Id-Version: pyramid_fullauth 0.
|
|
10
|
+
"Project-Id-Version: pyramid_fullauth 0.4.0\n"
|
|
11
11
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
|
12
|
-
"POT-Creation-Date:
|
|
12
|
+
"POT-Creation-Date: 2015-02-10 00:36+0100\n"
|
|
13
13
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
14
14
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
15
15
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
@@ -18,16 +18,16 @@ msgstr ""
|
|
|
18
18
|
"Content-Transfer-Encoding: 8bit\n"
|
|
19
19
|
"Generated-By: Babel 1.3\n"
|
|
20
20
|
|
|
21
|
-
#: pyramid_fullauth/tools.py:
|
|
21
|
+
#: pyramid_fullauth/tools.py:50
|
|
22
22
|
msgid "Please enter your password"
|
|
23
23
|
msgstr ""
|
|
24
24
|
|
|
25
|
-
#: pyramid_fullauth/tools.py:
|
|
25
|
+
#: pyramid_fullauth/tools.py:56
|
|
26
26
|
msgid "Password is too short"
|
|
27
27
|
msgstr ""
|
|
28
28
|
|
|
29
|
-
#: pyramid_fullauth/tools.py:
|
|
30
|
-
#: pyramid_fullauth/views/basic/profile/password.py:
|
|
29
|
+
#: pyramid_fullauth/tools.py:64
|
|
30
|
+
#: pyramid_fullauth/views/basic/profile/password.py:123
|
|
31
31
|
msgid "password-mismatch"
|
|
32
32
|
msgstr ""
|
|
33
33
|
|
|
@@ -100,7 +100,7 @@ msgid "Change your email"
|
|
|
100
100
|
msgstr ""
|
|
101
101
|
|
|
102
102
|
#: pyramid_fullauth/resources/templates/email_change.mako:15
|
|
103
|
-
#: pyramid_fullauth/resources/templates/login.mako:
|
|
103
|
+
#: pyramid_fullauth/resources/templates/login.mako:12
|
|
104
104
|
#: pyramid_fullauth/resources/templates/register.mako:13
|
|
105
105
|
#: pyramid_fullauth/resources/templates/reset.mako:15
|
|
106
106
|
#: pyramid_fullauth/resources/templates/reset.proceed.mako:14
|
|
@@ -120,7 +120,7 @@ msgstr ""
|
|
|
120
120
|
msgid "Welcome, to pyramid_fullauth!"
|
|
121
121
|
msgstr ""
|
|
122
122
|
|
|
123
|
-
#: pyramid_fullauth/resources/templates/login.mako:
|
|
123
|
+
#: pyramid_fullauth/resources/templates/login.mako:10
|
|
124
124
|
msgid "Please, log in"
|
|
125
125
|
msgstr ""
|
|
126
126
|
|
|
@@ -149,23 +149,23 @@ msgstr ""
|
|
|
149
149
|
msgid "Recover your password - choose new password"
|
|
150
150
|
msgstr ""
|
|
151
151
|
|
|
152
|
-
#: pyramid_fullauth/views/social.py:
|
|
152
|
+
#: pyramid_fullauth/views/social.py:139
|
|
153
153
|
msgid "Your account is already connected to other ${provider} account."
|
|
154
154
|
msgstr ""
|
|
155
155
|
|
|
156
|
-
#: pyramid_fullauth/views/social.py:
|
|
156
|
+
#: pyramid_fullauth/views/social.py:146
|
|
157
157
|
msgid "Your account has been connected to ${provider} account."
|
|
158
158
|
msgstr ""
|
|
159
159
|
|
|
160
|
-
#: pyramid_fullauth/views/social.py:
|
|
160
|
+
#: pyramid_fullauth/views/social.py:152
|
|
161
161
|
msgid "This ${provider} account is already connected with other account."
|
|
162
162
|
msgstr ""
|
|
163
163
|
|
|
164
|
-
#: pyramid_fullauth/views/basic/forbidden.py:
|
|
164
|
+
#: pyramid_fullauth/views/basic/forbidden.py:38
|
|
165
165
|
msgid "forbidden-notallowed"
|
|
166
166
|
msgstr ""
|
|
167
167
|
|
|
168
|
-
#: pyramid_fullauth/views/basic/forbidden.py:
|
|
168
|
+
#: pyramid_fullauth/views/basic/forbidden.py:43
|
|
169
169
|
msgid "forbidden-login"
|
|
170
170
|
msgstr ""
|
|
171
171
|
|
|
@@ -178,35 +178,35 @@ msgid "Already logged in!"
|
|
|
178
178
|
msgstr ""
|
|
179
179
|
|
|
180
180
|
#: pyramid_fullauth/views/basic/login.py:95
|
|
181
|
-
#: pyramid_fullauth/views/basic/login.py:
|
|
181
|
+
#: pyramid_fullauth/views/basic/login.py:126
|
|
182
182
|
msgid "Wrong e-mail or password."
|
|
183
183
|
msgstr ""
|
|
184
184
|
|
|
185
|
-
#: pyramid_fullauth/views/basic/register.py:
|
|
185
|
+
#: pyramid_fullauth/views/basic/register.py:39
|
|
186
186
|
msgid "You have an error in your registration form"
|
|
187
187
|
msgstr ""
|
|
188
188
|
|
|
189
|
-
#: pyramid_fullauth/views/basic/register.py:
|
|
189
|
+
#: pyramid_fullauth/views/basic/register.py:52
|
|
190
190
|
msgid "You have successfully registered"
|
|
191
191
|
msgstr ""
|
|
192
192
|
|
|
193
|
-
#: pyramid_fullauth/views/basic/register.py:
|
|
193
|
+
#: pyramid_fullauth/views/basic/register.py:76
|
|
194
194
|
msgid "User with given e-mail already exists!"
|
|
195
195
|
msgstr ""
|
|
196
196
|
|
|
197
|
-
#: pyramid_fullauth/views/basic/profile/email.py:
|
|
197
|
+
#: pyramid_fullauth/views/basic/profile/email.py:45
|
|
198
198
|
msgid "User with this email exists"
|
|
199
199
|
msgstr ""
|
|
200
200
|
|
|
201
|
-
#: pyramid_fullauth/views/basic/profile/email.py:
|
|
201
|
+
#: pyramid_fullauth/views/basic/profile/email.py:61
|
|
202
202
|
msgid "E-mail is empty"
|
|
203
203
|
msgstr ""
|
|
204
204
|
|
|
205
|
-
#: pyramid_fullauth/views/basic/profile/email.py:
|
|
205
|
+
#: pyramid_fullauth/views/basic/profile/email.py:67
|
|
206
206
|
msgid "Incorrect e-mail format"
|
|
207
207
|
msgstr ""
|
|
208
208
|
|
|
209
|
-
#: pyramid_fullauth/views/basic/profile/email.py:
|
|
209
|
+
#: pyramid_fullauth/views/basic/profile/email.py:74
|
|
210
210
|
msgid "We sent you email to activate your new email address"
|
|
211
211
|
msgstr ""
|
|
212
212
|
|
|
Binary file
|
|
Binary file
|
pyramid_fullauth/tools.py
CHANGED
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
import string
|
|
8
8
|
from random import choice
|
|
9
|
+
|
|
10
|
+
from pyramid.compat import text_type
|
|
11
|
+
|
|
9
12
|
from pyramid_fullauth.exceptions import (
|
|
10
13
|
EmptyError, ShortPasswordError, PasswordConfirmMismatchError
|
|
11
14
|
)
|
|
12
15
|
|
|
13
16
|
|
|
14
|
-
def password_generator(length, chars=(string.
|
|
17
|
+
def password_generator(length, chars=(string.ascii_letters + string.digits + string.punctuation)):
|
|
15
18
|
"""
|
|
16
19
|
Generate random password.
|
|
17
20
|
|
|
@@ -24,7 +27,7 @@ def password_generator(length, chars=(string.letters + string.digits + string.pu
|
|
|
24
27
|
:returns: password
|
|
25
28
|
:rtype: str
|
|
26
29
|
"""
|
|
27
|
-
return
|
|
30
|
+
return text_type(''.join([choice(chars) for i in range(length)]))
|
|
28
31
|
|
|
29
32
|
|
|
30
33
|
def validate_passsword(request, password, user=None):
|
|
@@ -55,7 +58,7 @@ def validate_passsword(request, password, user=None):
|
|
|
55
58
|
|
|
56
59
|
# here if password doesn't match
|
|
57
60
|
if password_config['confirm']:
|
|
58
|
-
confirm_password = request.POST.get('confirm_password',
|
|
61
|
+
confirm_password = request.POST.get('confirm_password', text_type(''))
|
|
59
62
|
if password != confirm_password:
|
|
60
63
|
raise PasswordConfirmMismatchError(
|
|
61
64
|
request._('password-mismatch',
|
pyramid_fullauth/tools.pyc
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"""Registration related views."""
|
|
6
6
|
|
|
7
7
|
from pyramid.view import view_config
|
|
8
|
-
from pyramid.httpexceptions import
|
|
8
|
+
from pyramid.httpexceptions import HTTPRedirection
|
|
9
9
|
from pyramid.security import NO_PERMISSION_REQUIRED
|
|
10
10
|
|
|
11
11
|
from sqlalchemy.orm.exc import NoResultFound
|
|
@@ -37,7 +37,7 @@ class ActivateView(BaseView):
|
|
|
37
37
|
response['status'] = False
|
|
38
38
|
try:
|
|
39
39
|
self.request.registry.notify(AfterActivate(self.request, user))
|
|
40
|
-
except
|
|
40
|
+
except HTTPRedirection as e:
|
|
41
41
|
# it's a redirect, let's follow it!
|
|
42
42
|
return e
|
|
43
43
|
|
|
Binary file
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
"""Forbidden views."""
|
|
6
6
|
|
|
7
7
|
from pyramid.view import forbidden_view_config
|
|
8
|
-
from pyramid.security import authenticated_userid
|
|
9
8
|
from pyramid.httpexceptions import HTTPFound
|
|
10
9
|
|
|
11
10
|
from pyramid_fullauth.views import BaseView
|
|
@@ -24,7 +23,7 @@ class ForbiddenViews(BaseView):
|
|
|
24
23
|
def forbidden(self):
|
|
25
24
|
"""Forbidden page view."""
|
|
26
25
|
# do not allow a user to login if they are already logged in
|
|
27
|
-
if
|
|
26
|
+
if self.request.authenticated_userid:
|
|
28
27
|
return {}
|
|
29
28
|
|
|
30
29
|
loc = self.request.route_path('login', _query=(('after', self.request.path),))
|
|
@@ -34,7 +33,7 @@ class ForbiddenViews(BaseView):
|
|
|
34
33
|
def forbidden_json(self):
|
|
35
34
|
"""Forbidden xhr response."""
|
|
36
35
|
# do not allow a user to login if they are already logged in
|
|
37
|
-
if
|
|
36
|
+
if self.request.authenticated_userid:
|
|
38
37
|
return {'status': False, 'msg':
|
|
39
38
|
self.request._('forbidden-notallowed',
|
|
40
39
|
default='You are not allowed to use this function',
|
|
Binary file
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
from pyramid.view import view_config
|
|
8
8
|
from pyramid.view import view_defaults
|
|
9
|
-
from pyramid.httpexceptions import
|
|
10
|
-
from pyramid.security import authenticated_userid
|
|
9
|
+
from pyramid.httpexceptions import HTTPSeeOther, HTTPRedirection
|
|
11
10
|
from pyramid.security import NO_PERMISSION_REQUIRED
|
|
12
11
|
|
|
13
12
|
from sqlalchemy.orm.exc import NoResultFound
|
|
13
|
+
from pyramid.compat import text_type
|
|
14
14
|
import pyramid_basemodel
|
|
15
15
|
|
|
16
16
|
from pyramid_fullauth.views import BaseView
|
|
@@ -40,11 +40,11 @@ class BaseLoginView(BaseView):
|
|
|
40
40
|
|
|
41
41
|
def _redirect_authenticated_user(self):
|
|
42
42
|
"""Redirect already logged in user away from login page."""
|
|
43
|
-
redirect =
|
|
43
|
+
redirect = HTTPSeeOther(location=self.response['after'])
|
|
44
44
|
try:
|
|
45
45
|
self.request.registry.notify(AlreadyLoggedIn(self.request))
|
|
46
|
-
except
|
|
47
|
-
|
|
46
|
+
except HTTPRedirection as e_redirect:
|
|
47
|
+
redirect = e_redirect
|
|
48
48
|
|
|
49
49
|
if self.request.is_xhr:
|
|
50
50
|
self.response['status'] = True
|
|
@@ -64,7 +64,7 @@ class LoginView(BaseLoginView):
|
|
|
64
64
|
|
|
65
65
|
def __call__(self):
|
|
66
66
|
"""Display login page."""
|
|
67
|
-
if
|
|
67
|
+
if self.request.authenticated_userid:
|
|
68
68
|
return self._redirect_authenticated_user()
|
|
69
69
|
|
|
70
70
|
self.request.registry.notify(BeforeLogIn(self.request, None))
|
|
@@ -82,7 +82,7 @@ class LoginViewPost(BaseLoginView):
|
|
|
82
82
|
|
|
83
83
|
def __call__(self):
|
|
84
84
|
"""Login action."""
|
|
85
|
-
if
|
|
85
|
+
if self.request.authenticated_userid:
|
|
86
86
|
return self._redirect_authenticated_user()
|
|
87
87
|
|
|
88
88
|
email = self.request.POST.get('email', '')
|
|
@@ -99,7 +99,7 @@ class LoginViewPost(BaseLoginView):
|
|
|
99
99
|
try:
|
|
100
100
|
self.request.registry.notify(BeforeLogIn(self.request, user))
|
|
101
101
|
except AttributeError as e:
|
|
102
|
-
self.response['msg'] =
|
|
102
|
+
self.response['msg'] = text_type(e)
|
|
103
103
|
return self.response
|
|
104
104
|
|
|
105
105
|
if user.check_password(password):
|
|
@@ -109,9 +109,9 @@ class LoginViewPost(BaseLoginView):
|
|
|
109
109
|
# if remember in POST set cookie timeout to one month
|
|
110
110
|
self.request.registry.notify(AfterLogIn(self.request, user))
|
|
111
111
|
except AttributeError as e:
|
|
112
|
-
self.response['msg'] =
|
|
112
|
+
self.response['msg'] = text_type(e)
|
|
113
113
|
return self.response
|
|
114
|
-
except
|
|
114
|
+
except HTTPRedirection as redirect:
|
|
115
115
|
login_kwargs['location'] = redirect.location
|
|
116
116
|
|
|
117
117
|
redirect = self.request.login_perform(user, **login_kwargs)
|
|
Binary file
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"""De-authentication related view."""
|
|
6
6
|
|
|
7
7
|
from pyramid.view import view_config
|
|
8
|
-
from pyramid.httpexceptions import
|
|
8
|
+
from pyramid.httpexceptions import HTTPSeeOther
|
|
9
9
|
from pyramid.security import NO_PERMISSION_REQUIRED
|
|
10
10
|
|
|
11
11
|
from pyramid_fullauth.views import BaseView
|
|
@@ -24,5 +24,5 @@ class LogoutView(BaseView):
|
|
|
24
24
|
# forget headers
|
|
25
25
|
self.request.logout()
|
|
26
26
|
|
|
27
|
-
return
|
|
28
|
-
|
|
27
|
+
return HTTPSeeOther(location=location,
|
|
28
|
+
headers=self.request.response.headers)
|
|
Binary file
|
|
Binary file
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
"""Email related views."""
|
|
6
6
|
|
|
7
7
|
from pyramid.view import view_config, view_defaults
|
|
8
|
-
from pyramid.httpexceptions import
|
|
8
|
+
from pyramid.httpexceptions import HTTPRedirection, HTTPSeeOther
|
|
9
9
|
from pyramid.security import NO_PERMISSION_REQUIRED
|
|
10
10
|
|
|
11
11
|
from sqlalchemy.orm.exc import NoResultFound
|
|
12
|
+
from pyramid.compat import text_type
|
|
12
13
|
import pyramid_basemodel
|
|
13
14
|
|
|
14
15
|
from pyramid_fullauth.views import BaseView
|
|
@@ -51,7 +52,7 @@ class EmailChangeViews(BaseView):
|
|
|
51
52
|
try:
|
|
52
53
|
self.request.registry.notify(BeforeEmailChange(self.request, user))
|
|
53
54
|
except AttributeError as e:
|
|
54
|
-
return {'status': False, 'msg': e
|
|
55
|
+
return {'status': False, 'msg': text_type(e), 'csrf_token': csrf_token}
|
|
55
56
|
|
|
56
57
|
try:
|
|
57
58
|
user.set_new_email(self.request.POST.get('email', ''))
|
|
@@ -76,7 +77,7 @@ class EmailChangeViews(BaseView):
|
|
|
76
77
|
|
|
77
78
|
try:
|
|
78
79
|
self.request.registry.notify(AfterEmailChange(self.request, user))
|
|
79
|
-
except
|
|
80
|
+
except HTTPRedirection as redirect:
|
|
80
81
|
if self.request.is_xhr:
|
|
81
82
|
response_values['url'] = redirect.location
|
|
82
83
|
return response_values
|
|
@@ -86,7 +87,7 @@ class EmailChangeViews(BaseView):
|
|
|
86
87
|
if self.request.is_xhr:
|
|
87
88
|
return response_values
|
|
88
89
|
else:
|
|
89
|
-
return
|
|
90
|
+
return HTTPSeeOther(location='/')
|
|
90
91
|
|
|
91
92
|
|
|
92
93
|
@view_config(route_name='email:change:continue', permission=NO_PERMISSION_REQUIRED,
|
|
@@ -102,6 +103,6 @@ class EmailChangeAccept(BaseView):
|
|
|
102
103
|
|
|
103
104
|
try:
|
|
104
105
|
self.request.registry.notify(AfterEmailChangeActivation(self.request, user))
|
|
105
|
-
except
|
|
106
|
+
except HTTPRedirection as redirect:
|
|
106
107
|
return redirect
|
|
107
|
-
return
|
|
108
|
+
return HTTPSeeOther(location='/')
|
|
Binary file
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
"""Profile related views."""
|
|
6
6
|
|
|
7
7
|
from pyramid.view import view_config, view_defaults
|
|
8
|
-
from pyramid.httpexceptions import
|
|
8
|
+
from pyramid.httpexceptions import HTTPRedirection, HTTPSeeOther
|
|
9
9
|
from pyramid.security import NO_PERMISSION_REQUIRED
|
|
10
10
|
|
|
11
11
|
from sqlalchemy.orm.exc import NoResultFound
|
|
12
|
+
from pyramid.compat import text_type
|
|
12
13
|
import pyramid_basemodel
|
|
13
14
|
|
|
14
15
|
from pyramid_fullauth.views import BaseView
|
|
@@ -45,17 +46,17 @@ class PasswordResetView(BaseView):
|
|
|
45
46
|
except NoResultFound:
|
|
46
47
|
return {'status': False,
|
|
47
48
|
'msg': self.request._('user-not-exists',
|
|
48
|
-
default='User does not
|
|
49
|
+
default='User does not exist',
|
|
49
50
|
domain='pyramid_fullauth'),
|
|
50
51
|
'csrf_token': csrf_token}
|
|
51
52
|
|
|
52
53
|
user.set_reset()
|
|
53
54
|
try:
|
|
54
55
|
self.request.registry.notify(AfterResetRequest(self.request, user))
|
|
55
|
-
except
|
|
56
|
+
except HTTPRedirection as redirect:
|
|
56
57
|
return redirect
|
|
57
58
|
|
|
58
|
-
return
|
|
59
|
+
return HTTPSeeOther(location='/')
|
|
59
60
|
|
|
60
61
|
|
|
61
62
|
@view_defaults(route_name='password:reset:continue', permission=NO_PERMISSION_REQUIRED,
|
|
@@ -94,12 +95,12 @@ class PasswordResetContinueView(BaseView):
|
|
|
94
95
|
try:
|
|
95
96
|
pyramid_basemodel.Session.query(AuthenticationProvider).filter(
|
|
96
97
|
AuthenticationProvider.user_id == user.id,
|
|
97
|
-
AuthenticationProvider.provider ==
|
|
98
|
+
AuthenticationProvider.provider == text_type('email')
|
|
98
99
|
).one()
|
|
99
100
|
except NoResultFound:
|
|
100
101
|
user.providers.append(
|
|
101
102
|
AuthenticationProvider(
|
|
102
|
-
provider=
|
|
103
|
+
provider=text_type('email'),
|
|
103
104
|
provider_id=user.id
|
|
104
105
|
)
|
|
105
106
|
)
|
|
@@ -108,13 +109,13 @@ class PasswordResetContinueView(BaseView):
|
|
|
108
109
|
except (ValidateError, AttributeError) as e:
|
|
109
110
|
return {
|
|
110
111
|
'status': False,
|
|
111
|
-
'msg':
|
|
112
|
+
'msg': text_type(e),
|
|
112
113
|
'csrf_token': self.request.session.get_csrf_token()
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
try:
|
|
116
117
|
self.request.registry.notify(AfterReset(self.request, user))
|
|
117
|
-
except
|
|
118
|
+
except HTTPRedirection as redirect:
|
|
118
119
|
return redirect
|
|
119
120
|
else:
|
|
120
121
|
return {
|
|
Binary file
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
"""Registration related views."""
|
|
6
6
|
|
|
7
7
|
from pyramid.view import view_config, view_defaults
|
|
8
|
-
from pyramid.httpexceptions import
|
|
8
|
+
from pyramid.httpexceptions import HTTPRedirection
|
|
9
9
|
from pyramid.security import NO_PERMISSION_REQUIRED
|
|
10
10
|
|
|
11
|
+
from pyramid.compat import text_type
|
|
11
12
|
import pyramid_basemodel
|
|
12
13
|
|
|
13
14
|
from pyramid_fullauth.views import BaseView
|
|
@@ -53,7 +54,7 @@ class RegisterView(BaseView):
|
|
|
53
54
|
|
|
54
55
|
try:
|
|
55
56
|
self.request.registry.notify(AfterRegister(self.request, user, response))
|
|
56
|
-
except
|
|
57
|
+
except HTTPRedirection as redirect:
|
|
57
58
|
return redirect
|
|
58
59
|
|
|
59
60
|
return response
|
|
@@ -68,7 +69,7 @@ class RegisterView(BaseView):
|
|
|
68
69
|
:returns: response
|
|
69
70
|
:rtype: dict
|
|
70
71
|
"""
|
|
71
|
-
email = self.request.POST.get('email',
|
|
72
|
+
email = self.request.POST.get('email', text_type(''))
|
|
72
73
|
# here if e-mail is already in database
|
|
73
74
|
|
|
74
75
|
if pyramid_basemodel.Session.query(User).filter(User.email == email).count() != 0:
|
|
@@ -81,15 +82,15 @@ class RegisterView(BaseView):
|
|
|
81
82
|
except ValidateError as e:
|
|
82
83
|
# do not overwrite existing error
|
|
83
84
|
if 'email' not in response['errors']:
|
|
84
|
-
response['errors']['email'] =
|
|
85
|
+
response['errors']['email'] = text_type(e)
|
|
85
86
|
|
|
86
87
|
if self.config.register.password.require:
|
|
87
88
|
try:
|
|
88
89
|
tools.validate_passsword(self.request,
|
|
89
|
-
self.request.POST.get('password',
|
|
90
|
+
self.request.POST.get('password', text_type('')),
|
|
90
91
|
user)
|
|
91
92
|
except ValidateError as e:
|
|
92
|
-
response['errors']['password'] = e
|
|
93
|
+
response['errors']['password'] = text_type(e)
|
|
93
94
|
else:
|
|
94
95
|
user.password = tools.password_generator(
|
|
95
96
|
self.config.register.password.length_min)
|
|
@@ -101,10 +102,10 @@ class RegisterView(BaseView):
|
|
|
101
102
|
|
|
102
103
|
# lets add AuthenticationProvider as email!
|
|
103
104
|
user.providers.append(
|
|
104
|
-
AuthenticationProvider(provider=
|
|
105
|
+
AuthenticationProvider(provider=text_type('email'), provider_id=user.id))
|
|
105
106
|
else:
|
|
106
107
|
return response
|
|
107
108
|
except AttributeError as e:
|
|
108
|
-
response['errors']['msg'] =
|
|
109
|
+
response['errors']['msg'] = text_type(e)
|
|
109
110
|
|
|
110
111
|
return response
|
|
Binary file
|
pyramid_fullauth/views/social.py
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
import logging
|
|
7
7
|
|
|
8
8
|
from pyramid.view import view_config
|
|
9
|
-
from pyramid.httpexceptions import
|
|
9
|
+
from pyramid.httpexceptions import HTTPRedirection
|
|
10
10
|
from pyramid.security import NO_PERMISSION_REQUIRED
|
|
11
11
|
|
|
12
12
|
from sqlalchemy.orm.exc import NoResultFound
|
|
13
13
|
from sqlalchemy.exc import IntegrityError
|
|
14
|
+
from pyramid.compat import text_type
|
|
14
15
|
import pyramid_basemodel
|
|
15
16
|
|
|
16
17
|
from pyramid_fullauth.views import BaseView
|
|
@@ -106,14 +107,14 @@ class SocialLoginViews(BaseView):
|
|
|
106
107
|
self.request.registry.notify(
|
|
107
108
|
AfterSocialRegister(
|
|
108
109
|
self.request, user, context.profile, response_values))
|
|
109
|
-
except
|
|
110
|
+
except HTTPRedirection as redirect:
|
|
110
111
|
# it's a redirect, let's follow it!
|
|
111
112
|
return redirect
|
|
112
113
|
|
|
113
114
|
# if we're here, user exists,
|
|
114
115
|
try:
|
|
115
116
|
self.request.registry.notify(AfterSocialLogIn(self.request, user, context.profile))
|
|
116
|
-
except
|
|
117
|
+
except HTTPRedirection as redirect:
|
|
117
118
|
# it's a redirect, let's follow it!
|
|
118
119
|
return self.request.login_perform(user, location=redirect.location)
|
|
119
120
|
else:
|
|
@@ -126,7 +127,7 @@ class SocialLoginViews(BaseView):
|
|
|
126
127
|
:param dict response_values:
|
|
127
128
|
|
|
128
129
|
:returns: response values with any message,
|
|
129
|
-
or
|
|
130
|
+
or HTTPRedirection if raised in SocialAccountAlreadyConnected
|
|
130
131
|
:rtype: dict
|
|
131
132
|
"""
|
|
132
133
|
context = self.request.context
|
|
@@ -157,7 +158,7 @@ class SocialLoginViews(BaseView):
|
|
|
157
158
|
self.request.registry.notify(
|
|
158
159
|
SocialAccountAlreadyConnected(
|
|
159
160
|
self.request, user, context.profile, response_values))
|
|
160
|
-
except
|
|
161
|
+
except HTTPRedirection as redirect:
|
|
161
162
|
# it's a redirect, let's follow it!
|
|
162
163
|
return redirect
|
|
163
164
|
return response_values
|
|
@@ -212,7 +213,9 @@ class SocialLoginViews(BaseView):
|
|
|
212
213
|
return context.profile['emails'][0]['value']
|
|
213
214
|
# generating some random email address based on social userid and provider domain
|
|
214
215
|
else:
|
|
215
|
-
return
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
return text_type(
|
|
217
|
+
'{0}@{1}'.format(
|
|
218
|
+
context.profile['accounts'][0]['userid'],
|
|
219
|
+
context.profile['accounts'][0]['domain']
|
|
220
|
+
)
|
|
218
221
|
)
|
|
Binary file
|
tests/__init__.pyc
CHANGED
|
Binary file
|
tests/conftest.py
CHANGED
|
@@ -51,7 +51,8 @@ def db_session(request):
|
|
|
51
51
|
|
|
52
52
|
engine = create_engine(connection, echo=False, poolclass=NullPool)
|
|
53
53
|
pyramid_basemodel.Session = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
|
|
54
|
-
pyramid_basemodel.bind_engine(
|
|
54
|
+
pyramid_basemodel.bind_engine(
|
|
55
|
+
engine, pyramid_basemodel.Session, should_create=True, should_drop=True)
|
|
55
56
|
|
|
56
57
|
def destroy():
|
|
57
58
|
transaction.commit()
|
tests/conftest.pyc
CHANGED
|
Binary file
|
tests/tools.py
CHANGED
tests/tools.pyc
CHANGED
|
Binary file
|
|
Binary file
|
tests/unit/test_groupfinder.pyc
CHANGED
|
Binary file
|