Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't login if auth_file.json is invalid #68

Open
valenting opened this issue Oct 28, 2014 · 1 comment
Open

Can't login if auth_file.json is invalid #68

valenting opened this issue Oct 28, 2014 · 1 comment

Comments

@valenting
Copy link
Contributor

If an auth_file.json isn't properly formatted (such as it contains an extra , or misses one), the login will fail.
Open up your browser's dev tools, and look at the request to
GET services/services.py/login?username=<>&password=<>

You will see the following stack trace

{"errorMessage": "", "errorType": 2, "errorTrace": "Traceback (most recent call last):
  File \"/home/vmchecker/public_html/services/services.py\", line 596, in login
    user = websutil.get_user(username, password)
  File \"/usr/local/lib/python2.6/dist-packages/vmchecker/websutil.py\", line 61, in get_user
    r = get_user_from_auth_files(username, password)
  File \"/usr/local/lib/python2.6/dist-packages/vmchecker/websutil.py\", line 76, in get_user_from_auth_files
    r = get_user_from_auth_file(vmpaths, username, password)
  File \"/usr/local/lib/python2.6/dist-packages/vmchecker/websutil.py\", line 92, in get_user_from_auth_file
    auth_dic = json.loads(auth_file_contents)['auth']
  File \"/usr/lib/pymodules/python2.6/simplejson/__init__.py\", line 384, in loads
    return _default_decoder.decode(s)
  File \"/usr/lib/pymodules/python2.6/simplejson/decoder.py\", line 402, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File \"/usr/lib/pymodules/python2.6/simplejson/decoder.py\", line 418, in raw_decode
    obj, end = self.scan_once(s, idx)
    JSONDecodeError: Expecting property name: line 6 column 5 (char 207)
"}

A try-catch should be inserted at websutil.py at line 92.

@calin-iorgulescu
Copy link
Contributor

Quote from the get_user() function in vmchecker/websutil.py:

    # allthough a misconfigured user can block access to any course,
    # we preffer early LOUD errors to silently ignored ones.
    # Fail fast, fail lowdly!

I believe that this was the intended behavior, so that mistakes could be spotted early on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants