当前位置: 首页>>代码示例>>Python>>正文


Python User.get_by_email方法代码示例

本文整理汇总了Python中app.user.models.User.get_by_email方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_email方法的具体用法?Python User.get_by_email怎么用?Python User.get_by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.user.models.User的用法示例。


在下文中一共展示了User.get_by_email方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sanity

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
    def test_sanity(self):
        rv = self.app.post('/users', data=dict(email="[email protected]", password="_foobar_"))
        data = json.loads(rv.data)
        token = str(data['session_token'])
        rv = self.app.put(
            self.ENDPOINT + str(data['id']),
            data=dict(email="[email protected]", password="_foobar_"),
            headers={'X-Session-Token': token}
        )
        self.assertEqual(rv.status, "200 OK")
        user = User.get_by_email('[email protected]')
        self.assertIsNotNone(user)
        self.assertTrue(user.verify_password('_foobar_'))

        rv = self.app.put(
            self.ENDPOINT + str(data['id']),
            data=dict(email="[email protected]", password="_foobar_new_"),
            headers={'X-Session-Token': token}
        )
        self.assertEqual(rv.status, "200 OK")
        user = User.get_by_email('[email protected]')
        self.assertIsNotNone(user)
        self.assertTrue(user.verify_password('_foobar_new_'))
        self.assertFalse(user.verify_password('_foobar_'))
        self.assertIsNone(User.get_by_email('[email protected]'))
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:27,代码来源:test_resources.py

示例2: test_get_by_email

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
 def test_get_by_email(self):
     email = "[email protected]"
     user = User.get_by_email(email)
     self.assertIsNone(user)
     User(email=email).put()
     user = User.get_by_email(email)
     self.assertIsNotNone(user)
     self.assertEqual(user.email, email)
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:10,代码来源:test_models.py

示例3: test_user_exists

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
 def test_user_exists(self):
     rv = self.app.post("/users", data=dict(email="[email protected]", password="_foobar_"))
     self.assertEqual(rv.status, "201 CREATED")
     self.assertTrue('session_token' in rv.data)
     self.assertIsNotNone(User.get_by_email("[email protected]"))
     rv = self.app.post("/users", data=dict(email="[email protected]", password="_foobar_"))
     self.assertEqual(rv.status, "400 BAD REQUEST")
     self.assertFalse('session_token' in rv.data)
     self.assertIsNotNone(User.get_by_email("[email protected]"))
     self.assertEqual(1, len(User.query().fetch(2)))
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:12,代码来源:test_resources.py

示例4: test_unauthenticated

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
 def test_unauthenticated(self):
     rv = self.app.put(self.ENDPOINT + str(1), data=dict(email="[email protected]", password="_foobar_"))
     self.assertEqual(rv.status, "401 UNAUTHORIZED")
     self.assertIsNone(User.get_by_email('[email protected]'))
     rv = self.app.post('/users', data=dict(email="[email protected]", password="_foobar_"))
     data = json.loads(rv.data)
     rv = self.app.put(self.ENDPOINT + str(data['id']), data=dict(email="[email protected]", password="_foobar_"))
     self.assertEqual(rv.status, "401 UNAUTHORIZED")
     self.assertIsNotNone(User.get_by_email('[email protected]'))
     self.assertIsNone(User.get_by_email('[email protected]'))
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:12,代码来源:test_resources.py

示例5: test_invalid_email

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
 def test_invalid_email(self):
     rv = self.app.post('/users', data=dict(email='[email protected]', password='_foobar_'))
     data = json.loads(rv.data)
     token = str(data['session_token'])
     rv = self.app.put(
         self.ENDPOINT + str(data['id']),
         data=dict(email="foobar"),
         headers={'X-Session-Token': token}
     )
     self.assertEqual(rv.status, '400 BAD REQUEST')
     self.assertIsNone(User.get_by_email('foobar'))
     self.assertIsNotNone(User.get_by_email('[email protected]'))
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:14,代码来源:test_resources.py

示例6: test_403

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
 def test_403(self):
     rv = self.app.post('/users', data=dict(email="[email protected]", password="_foobar_"))
     data = json.loads(rv.data)
     token = str(data['session_token'])
     rv = self.app.post('/users', data=dict(email="[email protected]", password="_foobar_"))
     data = json.loads(rv.data)
     rv = self.app.put(
         self.ENDPOINT + str(data['id']),
         data=dict(email='[email protected]'),
         headers={'X-Session-Token': token}
     )
     self.assertEqual(rv.status, '403 FORBIDDEN')
     self.assertIsNone(User.get_by_email('[email protected]'))
     self.assertIsNotNone(User.get_by_email('[email protected]'))
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:16,代码来源:test_resources.py

示例7: post

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
    def post(self):
        args = password_reset_post.parse_args()
        email = args['email']
        user = user_model.get_by_email(email)
        if user is None:
            api.abort(404, 'User not found')
        token = user.get_session_token(expiration=21600, password_reset=True)
        if mail.is_email_valid(config.get('mail_sender')):
            sender = config.get('mail_sender')
        else:
            app_id = app_identity.get_application_id()
            sender = "%s <[email protected]%s.appspotmail.com>" % (app_id, app_id)
        try:
            message = mail.EmailMessage()
            message.sender = sender
            message.subject = 'Password reset request'
            message.to = email
            message.body = '''
You're receiving this email because you requested a password reset.
Visit the following page to reset your password:

%s?reset_token=%s
''' % (config.get('password_reset_url'), token)
            message.send()
        except:
            api.abort(500)
        return '', 200
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:29,代码来源:resources.py

示例8: test_unknown_data

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
 def test_unknown_data(self):
     rv = self.app.post('/users', data=dict(email="[email protected]", password="_foobar_"))
     data = json.loads(rv.data)
     token = str(data['session_token'])
     rv = self.app.put(
         self.ENDPOINT + str(data['id']),
         data=dict(foo="bar"),
         headers={'X-Session-Token': token}
     )
     self.assertEqual(rv.status, "200 OK")
     user = User.get_by_email('[email protected]')
     self.assertIsNotNone(user)
     with self.assertRaises(AttributeError):
         user.foo
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:16,代码来源:test_resources.py

示例9: put

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
 def put(self, object_id):
     user = user_model.get_or_404(object_id, message='User not found')
     if g.user != user and not g.user.admin:
         api.abort(403)
     args = users_put.parse_args()
     email = args['email']
     password = args['password']
     if email is not None and user.email != email:
         if user_model.get_by_email(email) is not None:
             api.abort(400, 'Email is already registered')
         user.email = email
     if password is not None:
         user.set_password(password)
     user.put()
     return '', 200
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:17,代码来源:resources.py

示例10: unique_email

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
def unique_email(email):
    if not re.match(r"[^@][email protected][^@]+\.[^@]+", email):
        raise ValueError("Invalid email address")
    if User.get_by_email(email) is not None:
    	raise ValueError("Email is not unique")
    return email
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:8,代码来源:inputs.py

示例11: test_invalid_password

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_email [as 别名]
 def test_invalid_password(self):
     rv = self.app.post("/users", data=dict(email="[email protected]", password="foobar"))
     self.assertEqual(rv.status, "400 BAD REQUEST")
     self.assertFalse('session_token' in rv.data)
     self.assertIsNone(User.get_by_email("[email protected]"))
开发者ID:patrikpettersson,项目名称:rest-engine,代码行数:7,代码来源:test_resources.py


注:本文中的app.user.models.User.get_by_email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。