pyramid-fullauth 0.3.2__py2.7.egg → 0.6.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.
Files changed (104) hide show
  1. EGG-INFO/PKG-INFO +53 -11
  2. EGG-INFO/SOURCES.txt +4 -0
  3. EGG-INFO/requires.txt +11 -10
  4. pyramid_fullauth/__init__.py +4 -4
  5. pyramid_fullauth/__init__.pyc +0 -0
  6. pyramid_fullauth/auth.py +5 -4
  7. pyramid_fullauth/auth.pyc +0 -0
  8. pyramid_fullauth/compat.py +20 -0
  9. pyramid_fullauth/compat.pyc +0 -0
  10. pyramid_fullauth/config/default.yaml +1 -1
  11. pyramid_fullauth/events.py +1 -20
  12. pyramid_fullauth/events.pyc +0 -0
  13. pyramid_fullauth/exceptions.py +1 -7
  14. pyramid_fullauth/exceptions.pyc +0 -0
  15. pyramid_fullauth/models/__init__.py +7 -8
  16. pyramid_fullauth/models/__init__.pyc +0 -0
  17. pyramid_fullauth/models/extensions/__init__.py +38 -0
  18. pyramid_fullauth/models/extensions/__init__.pyc +0 -0
  19. pyramid_fullauth/models/mixins/__init__.py +3 -2
  20. pyramid_fullauth/models/mixins/__init__.pyc +0 -0
  21. pyramid_fullauth/models/mixins/email.py +58 -10
  22. pyramid_fullauth/models/mixins/email.pyc +0 -0
  23. pyramid_fullauth/models/mixins/password.py +5 -11
  24. pyramid_fullauth/models/mixins/password.pyc +0 -0
  25. pyramid_fullauth/request.py +6 -5
  26. pyramid_fullauth/request.pyc +0 -0
  27. pyramid_fullauth/resources/helpers/social.mako +3 -3
  28. pyramid_fullauth/resources/locale/pyramid_fullauth.pot +23 -23
  29. pyramid_fullauth/resources/templates/403.mako +1 -1
  30. pyramid_fullauth/resources/templates/_form.login.mako +1 -1
  31. pyramid_fullauth/resources/templates/_form.register.mako +1 -1
  32. pyramid_fullauth/resources/templates/_social.login.mako +1 -1
  33. pyramid_fullauth/resources/templates/activate.mako +1 -1
  34. pyramid_fullauth/resources/templates/email_change.mako +1 -1
  35. pyramid_fullauth/resources/templates/layout.mako +1 -1
  36. pyramid_fullauth/resources/templates/login.mako +1 -1
  37. pyramid_fullauth/resources/templates/register.mako +1 -1
  38. pyramid_fullauth/resources/templates/reset.mako +1 -1
  39. pyramid_fullauth/resources/templates/reset.proceed.mako +1 -1
  40. pyramid_fullauth/routing/__init__.py +1 -1
  41. pyramid_fullauth/routing/__init__.pyc +0 -0
  42. pyramid_fullauth/routing/predicates.py +4 -3
  43. pyramid_fullauth/routing/predicates.pyc +0 -0
  44. pyramid_fullauth/tools.py +7 -4
  45. pyramid_fullauth/tools.pyc +0 -0
  46. pyramid_fullauth/views/__init__.py +2 -3
  47. pyramid_fullauth/views/__init__.pyc +0 -0
  48. pyramid_fullauth/views/basic/__init__.py +1 -1
  49. pyramid_fullauth/views/basic/__init__.pyc +0 -0
  50. pyramid_fullauth/views/basic/activate.py +1 -2
  51. pyramid_fullauth/views/basic/activate.pyc +0 -0
  52. pyramid_fullauth/views/basic/forbidden.py +3 -5
  53. pyramid_fullauth/views/basic/forbidden.pyc +0 -0
  54. pyramid_fullauth/views/basic/login.py +28 -34
  55. pyramid_fullauth/views/basic/login.pyc +0 -0
  56. pyramid_fullauth/views/basic/logout.py +1 -2
  57. pyramid_fullauth/views/basic/logout.pyc +0 -0
  58. pyramid_fullauth/views/basic/profile/__init__.py +1 -1
  59. pyramid_fullauth/views/basic/profile/__init__.pyc +0 -0
  60. pyramid_fullauth/views/basic/profile/email.py +44 -37
  61. pyramid_fullauth/views/basic/profile/email.pyc +0 -0
  62. pyramid_fullauth/views/basic/profile/password.py +6 -7
  63. pyramid_fullauth/views/basic/profile/password.pyc +0 -0
  64. pyramid_fullauth/views/basic/register.py +53 -27
  65. pyramid_fullauth/views/basic/register.pyc +0 -0
  66. pyramid_fullauth/views/social.py +7 -5
  67. pyramid_fullauth/views/social.pyc +0 -0
  68. tests/__init__.pyc +0 -0
  69. tests/conftest.py +23 -10
  70. tests/conftest.pyc +0 -0
  71. tests/tools.pyc +0 -0
  72. tests/unit/test_default_settings.pyc +0 -0
  73. tests/unit/test_groupfinder.pyc +0 -0
  74. tests/unit/test_social_view.py +28 -26
  75. tests/unit/test_social_view.pyc +0 -0
  76. tests/unit/test_tools.pyc +0 -0
  77. tests/unit/test_user_active.pyc +0 -0
  78. tests/unit/test_user_admin.pyc +0 -0
  79. tests/unit/test_user_email.pyc +0 -0
  80. tests/unit/test_user_password.py +1 -1
  81. tests/unit/test_user_password.pyc +0 -0
  82. tests/unit/test_user_providers.pyc +0 -0
  83. tests/unit/test_user_repr.py +4 -4
  84. tests/unit/test_user_repr.pyc +0 -0
  85. tests/unit/test_validators.py +1 -1
  86. tests/unit/test_validators.pyc +0 -0
  87. tests/views/__init__.pyc +0 -0
  88. tests/views/conftest.py +5 -0
  89. tests/views/conftest.pyc +0 -0
  90. tests/views/test_activation.py +13 -6
  91. tests/views/test_activation.pyc +0 -0
  92. tests/views/test_email.py +2 -2
  93. tests/views/test_email.pyc +0 -0
  94. tests/views/test_events.py +107 -49
  95. tests/views/test_events.pyc +0 -0
  96. tests/views/test_login.py +23 -2
  97. tests/views/test_login.pyc +0 -0
  98. tests/views/test_login_social.py +97 -69
  99. tests/views/test_login_social.pyc +0 -0
  100. tests/views/test_logout.pyc +0 -0
  101. tests/views/test_register.py +9 -5
  102. tests/views/test_register.pyc +0 -0
  103. tests/views/test_reset.py +9 -4
  104. tests/views/test_reset.pyc +0 -0
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
1
+ # Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
2
  #
3
3
  # This module is part of pyramid_fullauth and is released under
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -7,40 +7,88 @@
7
7
  import re
8
8
  import uuid
9
9
 
10
- from sqlalchemy import Column
11
- from sqlalchemy import Unicode
12
- from sqlalchemy import String
10
+ from sqlalchemy import Column, Unicode, String
13
11
  from sqlalchemy.orm import validates
12
+ from sqlalchemy.ext.hybrid import hybrid_property
14
13
 
15
14
 
16
15
  from pyramid_fullauth.exceptions import EmptyError, EmailValidationError
16
+ from pyramid_fullauth.models.extensions import CaseInsensitive
17
17
 
18
18
  pattern_mail = re.compile(
19
19
  r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]{0,256}(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+){0,256}" # dot-atom
20
20
  # quoted-string, see also http://tools.ietf.org/html/rfc2822#section-3.2.5
21
21
  r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177 ]|\\[\001-\011\013\014\016-\177 ]){0,256}"'
22
22
  r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2}\.?)$)' # domain
23
- r'|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', re.IGNORECASE) # literal form, ipv4 address (SMTP 4.1.3)
23
+ # literal form, ipv4 address (SMTP 4.1.3)
24
+ r'|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', re.IGNORECASE)
24
25
 
25
26
 
26
27
  class UserEmailMixin(object):
27
-
28
28
  """User email fields and functionality."""
29
29
 
30
30
  __pattern_mail = pattern_mail
31
31
 
32
- email = Column(Unicode(254), unique=True, nullable=False) # RFC5321 and RFC3696(errata)
33
- new_email = Column(Unicode(254), unique=True, nullable=True) # RFC5321 and RFC3696(errata)
32
+ _email = Column('email', Unicode(254), unique=True, nullable=False) # RFC5321 and RFC3696(errata)
33
+ _new_email = Column('new_email', Unicode(254), unique=True, nullable=True) # RFC5321 and RFC3696(errata)
34
34
  email_change_key = Column(String(255), default=None, unique=True)
35
35
 
36
- @validates('email', 'new_email')
36
+ def __init__(self, *args, **kwargs):
37
+ """Switch possible email and new_email kwarg into new column attribute names."""
38
+ if 'email' in kwargs:
39
+ kwargs['_email'] = kwargs.pop('email')
40
+ if 'new_email' in kwargs:
41
+ kwargs['_new_email'] - kwargs.pop('new_email')
42
+
43
+ super(UserEmailMixin, self).__init__(*args, **kwargs)
44
+
45
+ @hybrid_property
46
+ def email(self):
47
+ """Email field getter."""
48
+ if self._email:
49
+ return self._email.lower()
50
+ return self._email
51
+
52
+ @email.setter
53
+ def email(self, value):
54
+ """Email field setter."""
55
+ if value:
56
+ value = value.lower()
57
+ self._email = value
58
+
59
+ @email.comparator
60
+ def email(cls):
61
+ """Email field comparator."""
62
+ return CaseInsensitive(cls._email)
63
+
64
+ @hybrid_property
65
+ def new_email(self):
66
+ """New email field getter."""
67
+ if self._new_email:
68
+ return self._new_email.lower()
69
+ return self._new_email
70
+
71
+ @new_email.setter
72
+ def new_email(self, value):
73
+ """New email field setter."""
74
+ if value:
75
+ value = value.lower()
76
+ self._new_email = value
77
+
78
+ @new_email.comparator
79
+ def new_email(cls):
80
+ """New email field comparator."""
81
+ return CaseInsensitive(cls._new_email)
82
+
83
+ @validates('_email', '_new_email')
37
84
  def validate_email(self, key, address):
38
85
  """
39
86
  Validate email addresses.
40
87
 
41
88
  .. note::
42
89
 
43
- See pyramid docs about `simple validators <http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#simple-validators>`_
90
+ See pyramid docs about
91
+ `simple validators <http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#simple-validators>`_
44
92
 
45
93
  :param str key: field key
46
94
  :param str address: email address
Binary file
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
1
+ # Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
2
  #
3
3
  # This module is part of pyramid_fullauth and is released under
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -15,28 +15,22 @@ from sqlalchemy import String
15
15
  from sqlalchemy.orm import validates
16
16
  from pyramid.compat import text_type
17
17
  from pyramid_fullauth.exceptions import EmptyError
18
-
19
- try: # pragma: no cover
20
- algorithms = hashlib.algorithms
21
- except AttributeError: # pragma: no cover
22
- # Simple tuple for Python 2.6
23
- algorithms = ('md5', 'sha1')
18
+ from pyramid_fullauth.compat import algorithms
24
19
 
25
20
 
26
21
  class UserPasswordMixin(object):
27
-
28
22
  """Authentication field definition along with appropriate methods."""
29
23
 
30
24
  #: password field
31
- password = Column(Unicode(40), nullable=False)
25
+ password = Column(Unicode(128), nullable=False)
32
26
 
33
27
  #: hash_algorithm field
34
28
  _hash_algorithm = Column('hash_algorithm',
35
29
  Enum(*algorithms, name="hash_algorithms_enum"),
36
- default=text_type('sha1'), nullable=False)
30
+ default=text_type('sha256'), nullable=False)
37
31
 
38
32
  #: salt field
39
- _salt = Column('salt', Unicode(50), nullable=False)
33
+ _salt = Column('salt', Unicode(128), nullable=False)
40
34
 
41
35
  #: reset key field
42
36
  reset_key = Column(String(255), unique=True)
Binary file
@@ -1,11 +1,11 @@
1
- # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
1
+ # Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
2
  #
3
3
  # This module is part of pyramid_fullauth and is released under
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
5
5
  """These method gets added to each ``pyramid.request.Request`` object."""
6
6
 
7
7
  from pyramid.httpexceptions import HTTPSeeOther
8
- from pyramid.security import remember, unauthenticated_userid, forget
8
+ from pyramid.security import remember, forget
9
9
  from sqlalchemy.sql.expression import func
10
10
  from sqlalchemy.orm.exc import NoResultFound
11
11
  import pyramid_basemodel
@@ -49,10 +49,11 @@ def user(request):
49
49
  :returns: logged in user object, or None
50
50
  :rtype: pyramid_fullauth.models.User
51
51
  """
52
- userid = unauthenticated_userid(request)
53
- if userid:
52
+ if request.unauthenticated_userid:
54
53
  try:
55
- user = pyramid_basemodel.Session.query(User).filter(User.id == userid).one()
54
+ user = pyramid_basemodel.Session.query(User).filter(
55
+ User.id == request.unauthenticated_userid
56
+ ).one()
56
57
  return user
57
58
  except NoResultFound: # pragma: no cover
58
59
  pass
Binary file
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2015 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -9,9 +9,9 @@ the MIT License (MIT): http://opensource.org/licenses/MIT
9
9
  <%def name="social_auth_uri(name, **kw)">
10
10
  <%
11
11
  from velruse import login_url
12
- import urllib
12
+ from pyramid_fullauth.compat import urlencode
13
13
  %>
14
14
  % if name in request.registry['config'].fullauth.social:
15
- ${login_url(request, name) + ('?{0}'.format(urllib.urlencode(kw)) if kw else '')}
15
+ ${login_url(request, name) + ('?{0}'.format(urlencode(kw)) if kw else '')}
16
16
  % endif
17
17
  </%def>
@@ -1,15 +1,15 @@
1
1
  # Translations template for pyramid_fullauth.
2
- # Copyright (C) 2014 ORGANIZATION
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>, 2014.
5
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2015.
6
6
  #
7
7
  #, fuzzy
8
8
  msgid ""
9
9
  msgstr ""
10
- "Project-Id-Version: pyramid_fullauth 0.2.3\n"
10
+ "Project-Id-Version: pyramid_fullauth 0.4.0\n"
11
11
  "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
12
- "POT-Creation-Date: 2014-04-11 23:41+0200\n"
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:47
21
+ #: pyramid_fullauth/tools.py:50
22
22
  msgid "Please enter your password"
23
23
  msgstr ""
24
24
 
25
- #: pyramid_fullauth/tools.py:53
25
+ #: pyramid_fullauth/tools.py:56
26
26
  msgid "Password is too short"
27
27
  msgstr ""
28
28
 
29
- #: pyramid_fullauth/tools.py:61
30
- #: pyramid_fullauth/views/basic/profile/password.py:124
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:11
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:9
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:134
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:141
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:147
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:39
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:44
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:133
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:38
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:51
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:75
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:44
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:60
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:66
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:73
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
 
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,6 +1,6 @@
1
1
  ## -*- coding: utf-8 -*-
2
2
  <%doc>
3
- Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
3
+ Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
4
4
 
5
5
  This module is part of pyramid_fullauth and is released under
6
6
  the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
1
+ # Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
2
  #
3
3
  # This module is part of pyramid_fullauth and is released under
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
Binary file
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
1
+ # Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
2
  #
3
3
  # This module is part of pyramid_fullauth and is released under
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -47,7 +47,9 @@ def change_email_hash(info, request):
47
47
  change_email_hash = info['match'].get('hash', None)
48
48
  if change_email_hash:
49
49
  try:
50
- info['match']['user'] = pyramid_basemodel.Session.query(User).filter(User.email_change_key == change_email_hash).one()
50
+ info['match']['user'] = pyramid_basemodel.Session.query(User).filter(
51
+ User.email_change_key == change_email_hash
52
+ ).one()
51
53
  return True
52
54
  except NoResultFound:
53
55
  pass
@@ -55,7 +57,6 @@ def change_email_hash(info, request):
55
57
 
56
58
 
57
59
  class CSRFCheckPredicate(CheckCSRFTokenPredicate):
58
-
59
60
  """
60
61
  Run csrf check dependant on configuration.
61
62
 
Binary file
pyramid_fullauth/tools.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
1
+ # Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
2
  #
3
3
  # This module is part of pyramid_fullauth and is released under
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -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.letters + string.digits + string.punctuation)):
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 u''.join([choice(chars) for i in range(length)])
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', u'')
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',
Binary file
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
1
+ # Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
2
  #
3
3
  # This module is part of pyramid_fullauth and is released under
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -6,8 +6,7 @@
6
6
 
7
7
 
8
8
  class BaseView(object):
9
-
10
- """basic view class."""
9
+ """Basic view class."""
11
10
 
12
11
  def __init__(self, request):
13
12
  """Common init for views."""
Binary file
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
1
+ # Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
2
  #
3
3
  # This module is part of pyramid_fullauth and is released under
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
Binary file
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
1
+ # Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
2
  #
3
3
  # This module is part of pyramid_fullauth and is released under
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
@@ -19,7 +19,6 @@ from pyramid_fullauth.events import AfterActivate
19
19
  @view_config(route_name='register:activate', permission=NO_PERMISSION_REQUIRED,
20
20
  renderer="pyramid_fullauth:resources/templates/activate.mako")
21
21
  class ActivateView(BaseView):
22
-
23
22
  """Activate account views."""
24
23
 
25
24
  def __call__(self):
Binary file
@@ -1,18 +1,16 @@
1
- # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
1
+ # Copyright (c) 2013 - 2016 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
2
  #
3
3
  # This module is part of pyramid_fullauth and is released under
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
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
12
11
 
13
12
 
14
13
  class ForbiddenViews(BaseView):
15
-
16
14
  """Forbidden related views."""
17
15
 
18
16
  def __init__(self, request):
@@ -24,7 +22,7 @@ class ForbiddenViews(BaseView):
24
22
  def forbidden(self):
25
23
  """Forbidden page view."""
26
24
  # do not allow a user to login if they are already logged in
27
- if authenticated_userid(self.request):
25
+ if self.request.authenticated_userid:
28
26
  return {}
29
27
 
30
28
  loc = self.request.route_path('login', _query=(('after', self.request.path),))
@@ -34,7 +32,7 @@ class ForbiddenViews(BaseView):
34
32
  def forbidden_json(self):
35
33
  """Forbidden xhr response."""
36
34
  # do not allow a user to login if they are already logged in
37
- if authenticated_userid(self.request):
35
+ if self.request.authenticated_userid:
38
36
  return {'status': False, 'msg':
39
37
  self.request._('forbidden-notallowed',
40
38
  default='You are not allowed to use this function',
Binary file