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
EGG-INFO/PKG-INFO
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.1
|
|
2
2
|
Name: pyramid-fullauth
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: This package intends to provide full authentication / authorisation
|
|
5
5
|
implementation for pyramid applications
|
|
6
6
|
Home-page: https://github.com/fizyk/pyramid_fullauth
|
|
@@ -14,6 +14,10 @@ Description: pyramid_fullauth
|
|
|
14
14
|
:target: https://pypi.python.org/pypi/pyramid_fullauth/
|
|
15
15
|
:alt: Latest PyPI version
|
|
16
16
|
|
|
17
|
+
.. image:: https://readthedocs.org/projects/pyramid_fullauth/badge/?version=v0.4.1
|
|
18
|
+
:target: https://readthedocs.org/projects/pyramid_fullauth/?badge=v0.4.1
|
|
19
|
+
:alt: Documentation Status
|
|
20
|
+
|
|
17
21
|
.. image:: https://pypip.in/d/pyramid_fullauth/badge.png
|
|
18
22
|
:target: https://pypi.python.org/pypi/pyramid_fullauth/
|
|
19
23
|
:alt: Number of PyPI downloads
|
|
@@ -35,17 +39,17 @@ Description: pyramid_fullauth
|
|
|
35
39
|
Package status
|
|
36
40
|
--------------
|
|
37
41
|
|
|
38
|
-
.. image:: https://travis-ci.org/fizyk/pyramid_fullauth.png?branch=
|
|
42
|
+
.. image:: https://travis-ci.org/fizyk/pyramid_fullauth.png?branch=v0.4.1
|
|
39
43
|
:target: https://travis-ci.org/fizyk/pyramid_fullauth
|
|
40
44
|
:alt: Tests
|
|
41
45
|
|
|
42
|
-
.. image:: https://coveralls.io/repos/fizyk/pyramid_fullauth/badge.png?branch=
|
|
43
|
-
:target: https://coveralls.io/r/fizyk/pyramid_fullauth?branch=
|
|
46
|
+
.. image:: https://coveralls.io/repos/fizyk/pyramid_fullauth/badge.png?branch=v0.4.1
|
|
47
|
+
:target: https://coveralls.io/r/fizyk/pyramid_fullauth?branch=v0.4.1
|
|
44
48
|
:alt: Coverage Status
|
|
45
49
|
|
|
46
|
-
.. image:: https://requires.io/github/fizyk/pyramid_fullauth/requirements.
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
.. image:: https://requires.io/github/fizyk/pyramid_fullauth/requirements.svg?tag=v0.4.1
|
|
51
|
+
:target: https://requires.io/github/fizyk/pyramid_fullauth/requirements/?tag=v0.4.1
|
|
52
|
+
:alt: Requirements Status
|
|
49
53
|
|
|
50
54
|
Package resources
|
|
51
55
|
-----------------
|
|
@@ -54,8 +58,8 @@ Description: pyramid_fullauth
|
|
|
54
58
|
* Documentation: http://pyramid-fullauth.readthedocs.org/
|
|
55
59
|
* PyPI: https://pypi.python.org/pypi/pyramid_fullauth
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
Installation
|
|
62
|
+
------------
|
|
59
63
|
|
|
60
64
|
``pip install pyramid_fullauth``
|
|
61
65
|
|
|
@@ -73,6 +77,39 @@ Description: pyramid_fullauth
|
|
|
73
77
|
CHANGELOG
|
|
74
78
|
=========
|
|
75
79
|
|
|
80
|
+
0.5.0
|
|
81
|
+
-------
|
|
82
|
+
|
|
83
|
+
- full python3 compatibility, since velruse migrated to py3 enabled requests-oauth
|
|
84
|
+
-require velruse 1.1.1
|
|
85
|
+
- run tests with sqlalchemy 1.0.x
|
|
86
|
+
- small updates to conform with new linters versions embedded in pylama
|
|
87
|
+
|
|
88
|
+
0.4.1
|
|
89
|
+
-------
|
|
90
|
+
|
|
91
|
+
- fixed spelling for error message when user does not exist while trying to reset password.
|
|
92
|
+
- require pyramid_basemodel at least version 0.3
|
|
93
|
+
|
|
94
|
+
0.4.0
|
|
95
|
+
-------
|
|
96
|
+
|
|
97
|
+
- python 3 compatibility (without oauth2 though)
|
|
98
|
+
- cleared use of deprecated function `pyramid.security.authenticated_userid` in favour of `pyramid.request.Request.authenticated_userid` attribute.
|
|
99
|
+
- make email fields case insensitive by using hybrid properties and CaseInsensitive comparator for model.
|
|
100
|
+
|
|
101
|
+
0.3.3
|
|
102
|
+
-------
|
|
103
|
+
|
|
104
|
+
- Fix issue where groupfined was returning empty list instead of None when user did not existed
|
|
105
|
+
|
|
106
|
+
0.3.2
|
|
107
|
+
-----
|
|
108
|
+
|
|
109
|
+
- catch all HTTPRedirect instead of just HTTPFound.
|
|
110
|
+
- redirect with HTTPSeeOther instead of HTTPFound where applicable.
|
|
111
|
+
|
|
112
|
+
|
|
76
113
|
0.3.1
|
|
77
114
|
-----
|
|
78
115
|
|
|
@@ -159,6 +196,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
159
196
|
Classifier: Natural Language :: English
|
|
160
197
|
Classifier: Operating System :: OS Independent
|
|
161
198
|
Classifier: Programming Language :: Python
|
|
162
|
-
Classifier: Programming Language :: Python :: 2.6
|
|
163
199
|
Classifier: Programming Language :: Python :: 2.7
|
|
200
|
+
Classifier: Programming Language :: Python :: 3.3
|
|
201
|
+
Classifier: Programming Language :: Python :: 3.4
|
|
164
202
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
EGG-INFO/SOURCES.txt
CHANGED
|
@@ -25,6 +25,7 @@ docs/source/api/request.rst
|
|
|
25
25
|
docs/source/api/tools.rst
|
|
26
26
|
pyramid_fullauth/__init__.py
|
|
27
27
|
pyramid_fullauth/auth.py
|
|
28
|
+
pyramid_fullauth/compat.py
|
|
28
29
|
pyramid_fullauth/events.py
|
|
29
30
|
pyramid_fullauth/exceptions.py
|
|
30
31
|
pyramid_fullauth/request.py
|
|
@@ -37,6 +38,7 @@ pyramid_fullauth.egg-info/requires.txt
|
|
|
37
38
|
pyramid_fullauth.egg-info/top_level.txt
|
|
38
39
|
pyramid_fullauth/config/default.yaml
|
|
39
40
|
pyramid_fullauth/models/__init__.py
|
|
41
|
+
pyramid_fullauth/models/extensions/__init__.py
|
|
40
42
|
pyramid_fullauth/models/mixins/__init__.py
|
|
41
43
|
pyramid_fullauth/models/mixins/email.py
|
|
42
44
|
pyramid_fullauth/models/mixins/password.py
|
EGG-INFO/requires.txt
CHANGED
|
@@ -2,8 +2,8 @@ pyramid_localize
|
|
|
2
2
|
pyramid >=1.4
|
|
3
3
|
pyramid_mako
|
|
4
4
|
tzf.pyramid_yml >=1.0
|
|
5
|
-
pyramid_basemodel
|
|
6
|
-
velruse
|
|
5
|
+
pyramid_basemodel>=0.3
|
|
6
|
+
velruse >=1.1.1
|
|
7
7
|
|
|
8
8
|
[docs]
|
|
9
9
|
sphinx
|
|
@@ -11,7 +11,5 @@ sphinx
|
|
|
11
11
|
[tests]
|
|
12
12
|
mock
|
|
13
13
|
pytest_pyramid
|
|
14
|
-
pytest-
|
|
15
|
-
mysql
|
|
16
|
-
psycopg2
|
|
17
|
-
pytest-cov
|
|
14
|
+
pytest-cov
|
|
15
|
+
pytest-dbfixtures[mysql,postgresql]
|
EGG-INFO/top_level.txt
CHANGED
pyramid_fullauth/__init__.py
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
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
|
"""Fullauth's configuration module."""
|
|
6
|
-
|
|
7
6
|
import logging
|
|
8
7
|
|
|
9
8
|
from tzf.pyramid_yml import config_defaults
|
|
@@ -17,7 +16,7 @@ from pyramid_fullauth.auth import groupfinder
|
|
|
17
16
|
from pyramid_fullauth.routing import predicates
|
|
18
17
|
from pyramid_fullauth.request import login_perform, logout, user
|
|
19
18
|
|
|
20
|
-
__version__ = '0.
|
|
19
|
+
__version__ = '0.5.0'
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
logger = logging.getLogger(__name__)
|
|
@@ -82,7 +81,8 @@ def includeme(configurator):
|
|
|
82
81
|
# scan base views
|
|
83
82
|
configurator.scan('pyramid_fullauth.views.basic')
|
|
84
83
|
|
|
85
|
-
# check for the social.
|
|
84
|
+
# check for the social.
|
|
85
|
+
# If social is not available, we will not turn it on!
|
|
86
86
|
if 'social' in fullauth_config:
|
|
87
87
|
# Velruse init (for social auth)
|
|
88
88
|
|
pyramid_fullauth/__init__.pyc
CHANGED
|
Binary file
|
pyramid_fullauth/auth.py
CHANGED
pyramid_fullauth/auth.pyc
CHANGED
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
# Copyright (c) 2013 - 2015 by pyramid_fullauth authors and contributors <see AUTHORS file>
|
|
3
|
+
#
|
|
4
|
+
# This module is part of pyramid_fullauth and is released under
|
|
5
|
+
# the MIT License (MIT): http://opensource.org/licenses/MIT
|
|
6
|
+
"""pyramid_fullauth's compatibility file for python2 and 3."""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
if sys.version_info.major == 2:
|
|
12
|
+
from urllib import urlencode
|
|
13
|
+
from urlparse import urlparse, parse_qs
|
|
14
|
+
else:
|
|
15
|
+
from urllib.parse import urlencode, urlparse, parse_qs
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__all__ = ('urlencode', 'urlparse', 'parse_qs')
|
|
Binary file
|
pyramid_fullauth/events.py
CHANGED
|
@@ -60,10 +60,12 @@ class AfterRegister(_BaseRegisterEvent):
|
|
|
60
60
|
User object is already in a session.
|
|
61
61
|
|
|
62
62
|
.. note::
|
|
63
|
-
Action emitting this event, should catch all
|
|
63
|
+
Action emitting this event, should catch all HTTPRedirection that might
|
|
64
|
+
be risen in event listener.
|
|
64
65
|
|
|
65
66
|
.. warning::
|
|
66
|
-
If
|
|
67
|
+
If HTTPRedirection is risen from event listener, then response_values
|
|
68
|
+
will not be used!
|
|
67
69
|
|
|
68
70
|
"""
|
|
69
71
|
|
|
@@ -85,7 +87,8 @@ class AfterActivate(_BaseRegisterEvent):
|
|
|
85
87
|
Add custom post-processing logic after user gets activated.
|
|
86
88
|
|
|
87
89
|
.. note::
|
|
88
|
-
Action emitting this event, should catch all
|
|
90
|
+
Action emitting this event, should catch all HTTPRedirection that might
|
|
91
|
+
be risen in event listener.
|
|
89
92
|
"""
|
|
90
93
|
|
|
91
94
|
pass
|
|
@@ -97,7 +100,8 @@ class AfterResetRequest(_BaseRegisterEvent):
|
|
|
97
100
|
Add custom post-processing after user sends request to reset password.
|
|
98
101
|
|
|
99
102
|
.. note::
|
|
100
|
-
Action emitting this event, should catch all
|
|
103
|
+
Action emitting this event, should catch all HTTPRedirection that might
|
|
104
|
+
be risen in event listener.
|
|
101
105
|
"""
|
|
102
106
|
|
|
103
107
|
pass
|
|
@@ -116,7 +120,8 @@ class AfterReset(_BaseRegisterEvent):
|
|
|
116
120
|
Add custom post-processing after the actual reset-password process.
|
|
117
121
|
|
|
118
122
|
.. note::
|
|
119
|
-
Action emitting this event, should catch all
|
|
123
|
+
Action emitting this event, should catch all HTTPRedirection that might
|
|
124
|
+
be risen in event listener.
|
|
120
125
|
"""
|
|
121
126
|
|
|
122
127
|
pass
|
|
@@ -128,7 +133,8 @@ class AlreadyLoggedIn(object):
|
|
|
128
133
|
Allow execute custom logic, when logged in user tries to log in again.
|
|
129
134
|
|
|
130
135
|
.. note::
|
|
131
|
-
Action emitting this event, should catch all
|
|
136
|
+
Action emitting this event, should catch all HTTPRedirection that might
|
|
137
|
+
be risen in event listener.
|
|
132
138
|
|
|
133
139
|
"""
|
|
134
140
|
|
|
@@ -147,7 +153,8 @@ class BeforeLogIn(_BaseRegisterEvent):
|
|
|
147
153
|
Add custom logic before user gets logged in.
|
|
148
154
|
|
|
149
155
|
.. note::
|
|
150
|
-
Action emitting this event, should catch all AttributeError that might
|
|
156
|
+
Action emitting this event, should catch all AttributeError that might
|
|
157
|
+
be risen in event listener.
|
|
151
158
|
User param set to None when user is not found or request method is GET.
|
|
152
159
|
"""
|
|
153
160
|
|
|
@@ -194,7 +201,8 @@ class AfterSocialRegister(_BaseSocialRegister):
|
|
|
194
201
|
Add custom logic after user registers through social network.
|
|
195
202
|
|
|
196
203
|
.. note::
|
|
197
|
-
Action emitting this event, should catch all
|
|
204
|
+
Action emitting this event, should catch all HTTPRedirection that might
|
|
205
|
+
be risen in event listener.
|
|
198
206
|
"""
|
|
199
207
|
|
|
200
208
|
def __init__(self, request, user, profile, response_values):
|
|
@@ -216,7 +224,8 @@ class AfterSocialLogIn(_BaseSocialRegister):
|
|
|
216
224
|
Custom logic after user logs in through social network.
|
|
217
225
|
|
|
218
226
|
.. note::
|
|
219
|
-
Action emitting this event, should catch all
|
|
227
|
+
Action emitting this event, should catch all HTTPRedirection that might
|
|
228
|
+
be risen in event listener.
|
|
220
229
|
"""
|
|
221
230
|
|
|
222
231
|
pass
|
|
@@ -225,10 +234,14 @@ class AfterSocialLogIn(_BaseSocialRegister):
|
|
|
225
234
|
class SocialAccountAlreadyConnected(_BaseSocialRegister):
|
|
226
235
|
|
|
227
236
|
"""
|
|
228
|
-
|
|
237
|
+
Event raised when social account is already connected to some other user.
|
|
238
|
+
|
|
239
|
+
Allow to add custom logic, when someone tries to connect social account to
|
|
240
|
+
second user in application.
|
|
229
241
|
|
|
230
242
|
.. note::
|
|
231
|
-
Action emitting this event, should catch all
|
|
243
|
+
Action emitting this event, should catch all HTTPRedirection that might
|
|
244
|
+
be risen in event listener.
|
|
232
245
|
"""
|
|
233
246
|
|
|
234
247
|
def __init__(self, request, user, profile, response_values):
|
pyramid_fullauth/events.pyc
CHANGED
|
Binary file
|
pyramid_fullauth/exceptions.pyc
CHANGED
|
Binary file
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import sys
|
|
8
8
|
import uuid
|
|
9
|
+
from datetime import datetime
|
|
9
10
|
|
|
10
11
|
from sqlalchemy import (
|
|
11
12
|
Column, Unicode, String, Integer, Boolean, Sequence, DateTime,
|
|
@@ -15,11 +16,11 @@ from sqlalchemy.sql import func
|
|
|
15
16
|
from sqlalchemy.orm import validates, relationship
|
|
16
17
|
from sqlalchemy.orm.session import object_session
|
|
17
18
|
from sqlalchemy.orm.util import has_identity
|
|
18
|
-
|
|
19
|
+
from pyramid.compat import text_type
|
|
19
20
|
from pyramid_basemodel import Base
|
|
21
|
+
|
|
20
22
|
from pyramid_fullauth import exceptions
|
|
21
23
|
from pyramid_fullauth.models.mixins import UserPasswordMixin, UserEmailMixin
|
|
22
|
-
from datetime import datetime
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
class User(UserPasswordMixin, UserEmailMixin, Base):
|
|
@@ -93,7 +94,7 @@ class User(UserPasswordMixin, UserEmailMixin, Base):
|
|
|
93
94
|
|
|
94
95
|
def __repr__(self):
|
|
95
96
|
"""Object representation."""
|
|
96
|
-
return "<User ('{0}'
|
|
97
|
+
return "<User ('{0}')>".format(self.id)
|
|
97
98
|
|
|
98
99
|
def __unicode__(self):
|
|
99
100
|
"""Unicode cast rules."""
|
|
@@ -102,7 +103,7 @@ class User(UserPasswordMixin, UserEmailMixin, Base):
|
|
|
102
103
|
elif self.email:
|
|
103
104
|
return self.email.split('@')[0] + '@...'
|
|
104
105
|
else:
|
|
105
|
-
return
|
|
106
|
+
return text_type(self.id)
|
|
106
107
|
|
|
107
108
|
def __str__(self): # pragma: no cover
|
|
108
109
|
"""String cast rules."""
|
|
Binary file
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Copyright (c) by SQLAlchemy authors and contributors.
|
|
2
|
+
#
|
|
3
|
+
# This module's code is part of SQLAlchemy's documentation
|
|
4
|
+
# http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/hybrid.html#hybrid-value-objects
|
|
5
|
+
# and released under
|
|
6
|
+
# the MIT License (MIT): http://opensource.org/licenses/MIT
|
|
7
|
+
"""CaseInsensitive comparator for sqlalchemy models."""
|
|
8
|
+
|
|
9
|
+
from sqlalchemy import func
|
|
10
|
+
from sqlalchemy.ext.hybrid import Comparator
|
|
11
|
+
from pyramid.compat import string_types
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CaseInsensitive(Comparator):
|
|
15
|
+
|
|
16
|
+
"""Hybrid value representing a lower case representation."""
|
|
17
|
+
|
|
18
|
+
def __init__(self, word):
|
|
19
|
+
"""Initialise comparator object."""
|
|
20
|
+
if isinstance(word, string_types):
|
|
21
|
+
self.word = word.lower()
|
|
22
|
+
elif isinstance(word, CaseInsensitive):
|
|
23
|
+
self.word = word.word
|
|
24
|
+
else:
|
|
25
|
+
self.word = func.lower(word)
|
|
26
|
+
|
|
27
|
+
def operate(self, op, other):
|
|
28
|
+
"""Operate."""
|
|
29
|
+
if not isinstance(other, CaseInsensitive):
|
|
30
|
+
other = CaseInsensitive(other)
|
|
31
|
+
return op(self.word, other.word)
|
|
32
|
+
|
|
33
|
+
def __clause_element__(self):
|
|
34
|
+
"""Get clause element for comparator.."""
|
|
35
|
+
return self.word
|
|
36
|
+
|
|
37
|
+
def __str__(self):
|
|
38
|
+
"""Cast element to."""
|
|
39
|
+
return self.word
|
|
Binary file
|
|
Binary file
|
|
@@ -7,13 +7,13 @@
|
|
|
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
|
|
@@ -29,11 +29,58 @@ class UserEmailMixin(object):
|
|
|
29
29
|
|
|
30
30
|
__pattern_mail = pattern_mail
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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.
|
|
Binary file
|
|
Binary file
|
pyramid_fullauth/request.py
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
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
|
-
from pyramid.httpexceptions import
|
|
8
|
-
from pyramid.security import remember,
|
|
7
|
+
from pyramid.httpexceptions import HTTPSeeOther
|
|
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
|
|
@@ -23,7 +23,7 @@ def login_perform(request, user, location=None, remember_me=False):
|
|
|
23
23
|
:param bool remember_me: if True set cookie max_age to one month (60 * 60 * 24 * 30 seconds)
|
|
24
24
|
|
|
25
25
|
:returns: redirect exception
|
|
26
|
-
:rtype: pyramid.httpexceptions.
|
|
26
|
+
:rtype: pyramid.httpexceptions.HTTPSeeOther
|
|
27
27
|
"""
|
|
28
28
|
user.logged_at = func.now()
|
|
29
29
|
if remember_me: # if remember in POST set cookie timeout to one from configure
|
|
@@ -36,7 +36,7 @@ def login_perform(request, user, location=None, remember_me=False):
|
|
|
36
36
|
|
|
37
37
|
# this remembers user immediately, without the need to redirect (see below)
|
|
38
38
|
request.response.headers.extend(headers)
|
|
39
|
-
return
|
|
39
|
+
return HTTPSeeOther(location=location, headers=request.response.headers)
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
def user(request):
|
|
@@ -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
|
-
|
|
53
|
-
if userid:
|
|
52
|
+
if request.unauthenticated_userid:
|
|
54
53
|
try:
|
|
55
|
-
user = pyramid_basemodel.Session.query(User).filter(
|
|
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
|
pyramid_fullauth/request.pyc
CHANGED
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## -*- coding: utf-8 -*-
|
|
2
2
|
<%doc>
|
|
3
|
-
Copyright (c) 2013 -
|
|
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
|
|
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(
|
|
15
|
+
${login_url(request, name) + ('?{0}'.format(urlencode(kw)) if kw else '')}
|
|
16
16
|
% endif
|
|
17
17
|
</%def>
|