Пример #1
0
def VerifyPassword(emailOrToken, password):
	# first try to authenticate by token
	user = User.VerifyAuthToken(emailOrToken)
	if user:
		print("Token valido!")
	if not user:
		# try to authenticate with email/password
		print("Token invalido, chekeando password")
		user = User.query.filter_by(email=emailOrToken).first()
		if not user or not check_password_hash(user.password, password):
			return False
	
	g.user = user
	return True
Пример #2
0
def Verify_password(email_or_token, password):
    """ Verifies token or password sent by the requester.

        :type email_or_token: str
        :param email_or_token: Email or token sent by the requester.

        :type password: str
        :param password: Encoded password to be verified.
    """

    user = User.VerifyAuthToken(email_or_token)
    if not user:
        user = User.query.filter_by(email=email_or_token).first()
        if not user or not check_password_hash(user.password, password):
            return False

    g.user = user
    return True