Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

"corrupt" .surfbird file causes errors #69

Open
Fubinator opened this issue Dec 11, 2017 · 1 comment
Open

"corrupt" .surfbird file causes errors #69

Fubinator opened this issue Dec 11, 2017 · 1 comment

Comments

@Fubinator
Copy link
Contributor

Fubinator commented Dec 11, 2017

Description

Changing the .surfbird file in different ways causes the app to throw different errors. We have to differentiate between two problems regarding this issue:

  1. The content of the .surfbird file is not valid JSON.
  2. The service object has missing/wrong data

Additional Information

Fixing the first point of the issue should be quite easy. If we take a look at the load()-method in the src/main/authentication/index.js file, we can see that the only safety check is if the file exists before parsing it to JSON. Maybe the the return of the JSON.parse function should be wrapped in a try-catch statement?

static load () {
    let file = path.join(Authentication.homePath(), '.surfbird')

    if (!fs.existsSync(file)) {
      return null
    }

    return JSON.parse(fs.readFileSync(file, 'utf-8'))
  }

For the second point we should maybe implement a check if the provided credentials are working and if not, ask the user to log in again to fix the file.

@pixeldesu
Copy link
Member

I guess we can implement multiple checks here. The one you noted, catching errors on load, and maybe another one for each client (checking if the object/keys are added properly, otherwise failing)

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

No branches or pull requests

2 participants