/usr/lib/python2.7/dist-packages/social/apps/django_app/me/models.py is in python-social-auth 1:0.2.21+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | """
MongoEngine Django models for Social Auth.
Requires MongoEngine 0.8.6 or higher.
"""
from django.conf import settings
from mongoengine import Document, ReferenceField
from mongoengine.queryset import OperationError
from social.utils import setting_name, module_member
from social.storage.django_orm import BaseDjangoStorage
from social.storage.mongoengine_orm import MongoengineUserMixin, \
MongoengineNonceMixin, \
MongoengineAssociationMixin, \
MongoengineCodeMixin
UNUSABLE_PASSWORD = '!' # Borrowed from django 1.4
def _get_user_model():
"""
Get the User Document class user for MongoEngine authentication.
Use the model defined in SOCIAL_AUTH_USER_MODEL if defined, or
defaults to MongoEngine's configured user document class.
"""
custom_model = getattr(settings, setting_name('USER_MODEL'), None)
if custom_model:
return module_member(custom_model)
try:
# Custom user model support with MongoEngine 0.8
from mongoengine.django.mongo_auth.models import get_user_document
return get_user_document()
except ImportError:
return module_member('mongoengine.django.auth.User')
USER_MODEL = _get_user_model()
class UserSocialAuth(Document, MongoengineUserMixin):
"""Social Auth association model"""
user = ReferenceField(USER_MODEL)
@classmethod
def user_model(cls):
return USER_MODEL
class Nonce(Document, MongoengineNonceMixin):
"""One use numbers"""
pass
class Association(Document, MongoengineAssociationMixin):
"""OpenId account association"""
pass
class Code(Document, MongoengineCodeMixin):
"""Mail validation single one time use code"""
pass
class DjangoStorage(BaseDjangoStorage):
user = UserSocialAuth
nonce = Nonce
association = Association
code = Code
@classmethod
def is_integrity_error(cls, exception):
return exception.__class__ is OperationError and \
'E11000' in exception.message
|