Token-granted users should appear in KnownUser, and should have a separate 'last token use' field (rather than 'last seen')
Current Behavior
Token-granted users don't appear in KnownUser, which causes unexpected crashes when viewing their profile details on the auth log
Traceback (most recent call last):
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/flask/app.py", line 2091, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/flask/app.py", line 2076, in wsgi_app
response = self.handle_exception(e)
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "<string>", line 2, in admin_dashboard
""" Rendering functions """
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/pony/orm/core.py", line 519, in new_func
result = func(*args, **kwargs)
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/publ/rendering.py", line 543, in admin_dashboard
rendered, _ = render_publ_template(
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/publ/rendering.py", line 131, in render_publ_template
text, etag, flask.g.needs_auth = do_render( # pylint:disable=assigning-non-slot
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/flask_caching/__init__.py", line 952, in decorated_function
rv = f(*args, **kwargs)
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/publ/rendering.py", line 115, in do_render
text = template.render(**args)
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/publ/template.py", line 53, in render
return flask.render_template_string(self.content, **args)
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/flask/templating.py", line 165, in render_template_string
return _render(ctx.app.jinja_env.from_string(source), context, ctx.app)
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/flask/templating.py", line 128, in _render
rv = template.render(context)
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/jinja2/environment.py", line 1291, in render
self.environment.handle_exception()
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 226, in top-level template code
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/jinja2/runtime.py", line 828, in _invoke
rv = self._func(*arguments)
File "<template>", line 175, in template
File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/beesbuzz.biz-NFomSJ_p-py3.8/lib/python3.8/site-packages/jinja2/utils.py", line 84, in from_obj
if hasattr(obj, "jinja_pass_arg"):
jinja2.exceptions.UndefinedError: 'None' has no attribute 'format'
Possible Solution
Ensure that the token-based user gets logged through the same path as browser-based users
The crash is actually from assuming that the user row has a last_seen in the dashboard template. But logging the token grant time is also a good idea anyway.
Expected Behavior
Token-granted users should appear in KnownUser, and should have a separate 'last token use' field (rather than 'last seen')
Current Behavior
Token-granted users don't appear in KnownUser, which causes unexpected crashes when viewing their profile details on the auth log
Possible Solution
Ensure that the token-based user gets logged through the same path as browser-based users
Steps to Reproduce (for bugs)
1. 2. 3. 4.
Context