Пример #1
0
def __deserialize_password_reset_token(token, **kwargs):
    expires_in = kwargs.get(
        "expires_in",
        _PASSWORD_RESET_TOKEN_EXPIRATION,
    )
    try:
        auth_id = TimedJSONWebSignatureSerializer(
            current_app.secret_key,
            expires_in=expires_in,
        ).loads(token)
        return to_ObjectId(auth_id)
    except BadSignature:
        return ObjectId()
Пример #2
0
 def test_to_ObjectId_None(self):
     object_id = to_ObjectId(None)
     assert isinstance(object_id, ObjectId)
Пример #3
0
 def test_to_ObjectId_ObjectId(self):
     object_id_a = ObjectId()
     object_id_b = to_ObjectId(object_id_a)
     assert object_id_a == object_id_b
Пример #4
0
 def test_to_ObjectId_string(self):
     string = "5f04b7ba96f5ca591762581f"
     object_id = to_ObjectId(string)
     assert object_id == ObjectId(string)
Пример #5
0
 def test_to_ObjectId_invalid(self):
     object_id = to_ObjectId("invalid")
     assert isinstance(object_id, ObjectId)
Пример #6
0
def get_user_by_auth_id(auth_id):
    return User.objects(auth_id=to_ObjectId(auth_id)).first()
Пример #7
0
def __deserialize_verification_token(token):
    try:
        auth_id = URLSafeSerializer(current_app.secret_key).loads(token)
        return to_ObjectId(auth_id)
    except BadSignature:
        return ObjectId()