Skip to content

AttributeError: 'NoneType' object has no attribute 'isoformat' in auth.py #1031

@jschwarzbeck-fi

Description

@jschwarzbeck-fi

The Class SimpleTokenPlugin allows the creation of expire-less tokens by leaving the expiration_date field on auth_simple_token table empty.

However, the get_user() method calls the isoformat() method on the field attribute, since the field's contents are null/None, the following exception is thrown:

AttributeError: 'NoneType' object has no attribute 'isoformat' in auth.py

A solution would be to make this field required (expiration_date), or, if allowed to be empty, to make a check before the conversion to isoformat() is called:

if row and row.expiration_date.isoformat() > utcnow().isoformat():

To

if row and (row.expiration_date is None or (row.expiration_date is not None and row.expiration_date.isoformat() > utcnow().isoformat())):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions