graphiti-api / spraypaint.js

Graphiti Client / Javascript ORM / JSONAPI
MIT License
108 stars 69 forks source link

Disable localStorage use when jwtStorage set to false #95

Closed bronsonholden closed 1 year ago

bronsonholden commented 3 years ago

When setting jwtStorage to false on your record base class, the internal credential storage backend was not properly being updated.

A minimal failing example of this that you can just run in Node is:

// Mock this since we're in Node
global.localStorage = {
  setItem: () => { console.log("Never should have come here!") }
}

const Spraypaint = require("spraypaint")
const ApplicationRecord = Spraypaint.SpraypaintBase.extend({})

ApplicationRecord.jwtStorage = false
ApplicationRecord.setJWT("token")

Reinitializing credential storage properly checks for this and disables it as expected.

richmolj commented 3 years ago

@paulholden2 thanks so much for this ❤️ ! Want to see if @wadetandy has any input just because I was very surprised at this one. Otherwise LGTM 👍

bronsonholden commented 3 years ago

@richmolj @wadetandy Gentle bump—not urgent as there's a workaround, but erroneously using localStorage could cause some snafus!

richmolj commented 3 years ago

Thanks @paulholden2 ❤️ ! @wadetandy LGTM?