コード例 #1
0
ファイル: authform.py プロジェクト: kamilion/kaizen
    def validate(self):
        """
        Do validation of the form contents.
        @return: True if the User object was successfully created, or False if it was not.
        """
        rv = Form.validate(self)
        if not rv:
            flash('A required field is empty', 'error')
            return False

         #  We need to find a user's id by their email address.
        user = User.get_user_from_email(self.email.data)

        if user is not None:
            self.email.errors.append('Email Address Exists')
            flash('Email Address Exists', 'error')
            return False

        user = User.make(self.email.data, self.password.data)

        if user is not None:
            self.user = user
            return True
        else:
            return False
コード例 #2
0
ファイル: authform.py プロジェクト: kamilion/kaizen
    def validate(self):
        """
        Do validation of the form contents.
        @return: A User object representing the found user, or None
        """
        rv = Form.validate(self)
        if not rv:
            flash('A required field is empty', 'error')
            return False

        identity = OTP(self.yubi_input.data).device_id

         #  We need to find a user's id by their Yubico Token ID.
        user = User.get_user_from_yubitoken(identity)

        if user is None:
            self.yubi_input.errors.append('Unknown Identity')
            flash('Unknown Identity', 'error')
            return False

        if not user.check_yubitoken(self.yubi_input.data):
            self.yubi_input.errors.append('Invalid Token')
            flash('Invalid Token', 'error')
            return False

        self.user = user
        return True
コード例 #3
0
ファイル: authform.py プロジェクト: kamilion/kaizen
    def validate(self):
        """
        Do validation of the form contents.
        @return: A User object representing the found user, or None
        """
        rv = Form.validate(self)
        if not rv:
            flash('A required field is empty', 'error')
            return False

         #  We need to find a user's id by their email address.
        user = User.get_user_from_email(self.email.data)

        if user is None:
            self.email.errors.append('Unknown Email Address')
            flash('Unknown Email Address', 'error')
            return False

        if not user.check_password(self.password.data):
            self.password.errors.append('Invalid password')
            flash('Invalid password', 'error')
            return False

        self.user = user
        return True