theLaborInVain / kdm-manager-api

The API used by https://kdm-manager.com and related Kingdom Death: Monster utilities.
Other
3 stars 0 forks source link

Login exceptions #45

Closed toconnell closed 3 years ago

toconnell commented 3 years ago

User OID: 666 Method: POST URL: http://api.kdm-manager.com/login JSON: {'username': 'XXXXXXXX@XXXXXX.XXX', 'password': 'XXXXXXXX'}


Traceback (most recent call last):
File "/home/toconnell/kdm-manager-api/venv/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
 rv = self.dispatch_request()
File "/home/toconnell/kdm-manager-api/venv/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
 return self.view_functions[rule.endpoint](**req.view_args)
File "/home/toconnell/kdm-manager-api/app/utils/crossdomain.py", line 56, in wrapped_function
 resp = flask.make_response(func(*args, **kwargs))
File "/home/toconnell/kdm-manager-api/app/routes.py", line 318, in get_token
 flask.request.json.get("password", None)
File "/home/toconnell/kdm-manager-api/app/models/users.py", line 85, in authenticate
 U = User(_id=user["_id"])
File "/home/toconnell/kdm-manager-api/app/models/users.py", line 436, in __init__
 flask.request.User.user['login'] == self.user['login']
AttributeError: 'noUser' object has no attribute 'user'
toconnell commented 3 years ago

Interestingly, I don't think these are ultimately proving fatal: I saw this guy, for instance, show up in the logs right after this doing some basic management tasks...

toconnell commented 3 years ago

The phenomenon is expanding:

User OID: 6090df8c2b4f5220935998c6 Method: POST URL: http://api.kdm-manager.com/survivor/rm_game_asset/6090ede22b4f5220935998d4 JSON: {'handle': 'unconscious_fighter', 'type': 'fighting_arts', 'serialize_on_response': True}

Traceback (most recent call last):
File "/home/toconnell/kdm-manager-api/venv/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
 rv = self.dispatch_request()
File "/home/toconnell/kdm-manager-api/venv/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
 return self.view_functions[rule.endpoint](**req.view_args)
File "/home/toconnell/kdm-manager-api/app/utils/crossdomain.py", line 56, in wrapped_function
 resp = flask.make_response(func(*args, **kwargs))
File "/home/toconnell/kdm-manager-api/app/routes.py", line 470, in collection_action
 return asset_object.request_response(action)
File "/home/toconnell/kdm-manager-api/app/models/survivors/__init__.py", line 3645, in request_response
 self.rm_game_asset()
File "/home/toconnell/kdm-manager-api/app/models/survivors/__init__.py", line 1417, in rm_game_asset
 self.default_attribute(ak)
File "/home/toconnell/kdm-manager-api/app/models/survivors/__init__.py", line 2684, in default_attribute
 if attrib not in DEFAULTS.keys():
NameError: name 'DEFAULTS' is not defined
toconnell commented 3 years ago

Added a 'user' attrib to noUser and rewrote the check in users.py to do a .get() check with a default of None on the 'login' key, so hopefully we should sail right through that when doing a noUser operation now.

That resolves the first bit.

toconnell commented 3 years ago

For the second thing, which is a problem accessing the class constant DEFAULT, I just added 'self' to that, which should fix us up at that part.

I also caught a typo later on in that method and fixed that, QAing against the Unconscious Fighter FA, which is what fucked us up on the first place.

Anyway, tl;dr, I think we're fixed on the second thing:

[2021-05-13 09:23:32] INFO:     [0.182199] __init__(, _id: 609c8eb961c5608946c35f12 normalize_on_init: False)
[2021-05-13 09:23:33] INFO:     Desdemona [F] (609c8eb961c5608946c35f27) event: xxx@gmail.com defaulted Desdemona [F] 'max_bleeding_tokens' to 5.
[2021-05-13 09:23:33] INFO:     Saved Desdemona [F] (609c8eb961c5608946c35f27) to mdb.survivors successfully!
[2021-05-13 09:23:33] INFO:     Desdemona [F] (609c8eb961c5608946c35f27) event: xxx@gmail.com removed Unconscious Fighter from Desdemona [F] Fighting Arts.
[2021-05-13 09:23:33] INFO:     Saved Desdemona [F] (609c8eb961c5608946c35f27) to mdb.survivors successfully!