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


Python User.objects方法代码示例

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


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

示例1: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
    def post(self):
        args = fbUserParser.parse_args()
        fb_id = args['fbid']
        fb_token = args['fbtoken']   
        if fb_id is None or fb_token is None:
           abort(400)

        fbuser_info = requests.get('https://graph.facebook.com/me?access_token=%s' %fb_token).json()
        if not fbuser_info.get('id') or fb_id != fbuser_info['id']:
            raise InvalidUsage('User info does not match',406)

        fb_email = args['fbemail']
        user = User.objects(email=fb_email).first()
        
        if user is None:
            user = User(email=fb_email, fb_id=fbuser_info['id'])
            user.save()
            
        profile = Profile.objects(user=user).first()
        if profile is None:
            profile = Profile(user=user)
            profile.save()

        rongToken = rongcloudToken(profile.id)
        token = user.generate_auth_token()
        redis_store.set(str(user.id), token)
        return {'token': token, 'rongToken' : rongToken}
开发者ID:bintao,项目名称:cteemo,代码行数:29,代码来源:userAPI.py

示例2: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
    def post(self):
        """
        Login in with a Facebook account if the user has existed
        Otherwises, create a new user with information from Facebook
        """
        args = fbUserParser.parse_args()
        fb_id = args['fbid']
        fb_token = args['fbtoken']
        if fb_id is None or fb_token is None:
            abort(400)

        # verify the user's facebook account using the facebook token
        fbuser_info = requests.get(
            'https://graph.facebook.com/me?access_token=%s' % fb_token).json()
        if not fbuser_info.get('id') or fb_id != fbuser_info['id']:
            abort(406)

        fb_email = args['fbemail']
        user = User.objects(email=fb_email).first()

        if user is None:
            user = User(email=fb_email, fb_id=fbuser_info['id'])
            user.save()

        token = user.generate_auth_token(expiration=360000)
        redis_store.set(str(user.id), token)
        return {'token': token}
开发者ID:Xuefeng-Zhu,项目名称:flask-user-api,代码行数:29,代码来源:userAPI.py

示例3: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
    def post(self):
        """
        Verify the information from user
        Send a reset password email if the information is correct
        """
        args = forgetPasswordParser.parse_args()
        email = args['email']
        username = args['username']
        school = args['school']

        if email is None or username is None or school is None:
            abort(400)

        user = User.objects(email=email).first()
        if user is None:
            return {'status': 'error', 'message':
                    'There is no user associated with the email'}

        profile = Profile.objects(user=user).first()
        if not profile.checkInfo(username, school):
            return {'status': 'error', 'message':
                    'The information does not match the record'}

        token = user.generate_auth_token(expiration=360000)
        send_forget_password_email(email, token)

        return {'status': 'success', 'message':
                'An email has been sent to you letting you reset password'}
开发者ID:Xuefeng-Zhu,项目名称:flask-user-api,代码行数:30,代码来源:passwordAPI.py

示例4: login

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
def login(user_info):
	result = User.objects(email = user_info['email'], password = user_info['password'])
	if len(result) > 0:
		login_user(result[0])
		return True
	else:
		return False
开发者ID:velicue,项目名称:contestify,代码行数:9,代码来源:userauth.py

示例5: get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
 def get(self, user_id):
     """
     Renew the authorisation token by providing old token
     """
     user = User.objects(id=user_id).first()
     token = user.generate_auth_token(expiration=360000)
     redis_store.set(user_id, token)
     return {'token': token}
开发者ID:Xuefeng-Zhu,项目名称:flask-user-api,代码行数:10,代码来源:userAPI.py

示例6: monitoring

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
def monitoring():
    if not g.user.editor:
        redirect('/')

    users = User.objects(editor=False)
    exercises = Exercise.objects()
    progress = {user: {p.exercise: p for p in ExerciseProgress.objects(user=user)} for user in users}

    breadcrumbs = [('Home', '/'), ('Monitoring', None)]
    return render_template('monitoring.html', users=users, exercises=exercises, progress=progress, breadcrumbs=breadcrumbs)
开发者ID:INSA-4IF-SpecIFic,项目名称:elif,代码行数:12,代码来源:web.py

示例7: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
 def post(self):
     username = request.form.get('username')
     password = request.form.get('password')
     if username is None or password is None:
         abort(400)
     user = User.objects(username=username)[0]
     if not user or not user.verify_password(password):
         abort(400)
     token = user.generate_auth_token(expiration=360000)
     redis_store.set(username, token)
     return {'token': token}
开发者ID:Xuefeng-Zhu,项目名称:flask-sample,代码行数:13,代码来源:userAPI.py

示例8: process_login

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
def process_login():
    email, password = request.form['email'].lower(), request.form['password']
    user = User.objects(email=email).first()
    if user is None or not user.valid_password(password):
        app.logger.warning("Couldn't login : {}".format(user))
        return render_template('login.html', error="Wrong password or username.", email=email)
    else:
        session['logged_in'] = user.email
        inject_user()
        load_user()
        return redirect('/')
开发者ID:INSA-4IF-SpecIFic,项目名称:elif,代码行数:13,代码来源:web.py

示例9: send_digest

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
def send_digest():
    users = User.objects()
    contests = OperationData.getContests(1) 
    body = """
        We had %d contests yesterday! Come and see what's new contests on contestify!
    """ % contests
    count = 0
    for user in users:
        send_email(user.email, "Come and Read the latest Info!", body)
        print 'sent email to %s with body %s' % (user.email, body)
        count = count + 1
        if count > 0:
            break
开发者ID:velicue,项目名称:contestify,代码行数:15,代码来源:util.py

示例10: get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
    def get(self):
        args = activateAccountParser.parse_args()
        token = args['token']
        if token is None:
            abort()

        user_id = load_token(token)
        user = User.objects(id=user_id).first()
        if user is None:
            abort(400)
        user.is_activated = True
        user.save()

        return "Your account has been activated!"
开发者ID:bintao,项目名称:cteemo,代码行数:16,代码来源:userAPI.py

示例11: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
    def post(self, user_id):
        args = passwordParser.parse_args()
        old_password = args['old_password']
        new_password = args['new_password']
        if old_password is None or new_password is None:
            abort(400)    

        user = User.objects(id=user_id).first()
        if not user.verify_password(old_password):
            raise InvalidUsage('Password incorrect',401)
        user.hash_password(new_password)
        user.save()

        return {'status': 'success'}
开发者ID:bintao,项目名称:cteemo,代码行数:16,代码来源:passwordAPI.py

示例12: get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
    def get(self):
        args = forgetPasswordParser.parse_args()
        token = args['token']

        if token is None:
            abort(400)

        user_id = load_token(token)
        user = User.objects(id=user_id).first()
        if user is None:
            raise InvalidUsage('User not found',404)

        temp_password = (''.join(str(random.randint(0, 9)) for x in range(8)))
        user.hash_password(temp_password)
        user.save()
        
        return "Your temperate password is: %s" %temp_password
开发者ID:bintao,项目名称:cteemo,代码行数:19,代码来源:passwordAPI.py

示例13: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
    def post(self):
        args = userParser.parse_args()
        email = args['email']
        password = args['password']
        if email is None or password is None:
            abort(400)

        user = User.objects(email=email).first()

        if not user or not user.verify_password(password):
            return {'status': 'error', 'message':
                    'The email does not exist or password is wrong'}
        if not user.is_activated:
            return {'status': 'error', 'message':
                    'The account has not been activated'}

        token = user.generate_auth_token(expiration=360000)
        redis_store.set(str(user.id), token)
        return {'token': token}
开发者ID:bintao,项目名称:cteemo,代码行数:21,代码来源:userAPI.py

示例14: get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
    def get(self):
        """
        Reset user's password and return the temporary password
        """
        args = forgetPasswordParser.parse_args()
        token = args['token']

        if token is None:
            abort(400)

        user_id = load_token(token)
        user = User.objects(id=user_id).first()
        if user is None:
            return {'status': 'error', 'token': 'Token is not valid'}

        # generate a random temporary password
        temp_password = (''.join(str(random.randint(0, 9)) for x in range(8)))
        user.hash_password(temp_password)
        user.save()

        return "Your temperate password is: %s" % temp_password
开发者ID:Xuefeng-Zhu,项目名称:flask-user-api,代码行数:23,代码来源:passwordAPI.py

示例15: get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import objects [as 别名]
 def get(self, user_id):
     user = User.objects(id=user_id).first()
     token = user.generate_auth_token(expiration=360000)
     redis_store.set(user_id, token)
     return {'token': token}
开发者ID:bintao,项目名称:cteemo,代码行数:7,代码来源:userAPI.py


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