Giter VIP home page Giter VIP logo

Comments (10)

ianstalter123 avatar ianstalter123 commented on July 17, 2024

Trying to understand how sessions work after logout here -- does get-session.js , need to be called or something similar in fetch.js?

from hoodie-account-client.

gr2m avatar gr2m commented on July 17, 2024

in account.signOut, we clear the session here: https://github.com/hoodiehq/hoodie-client-account/blob/master/lib/signout.js#L20, which removes state.session so it becomes undefined here: https://github.com/hoodiehq/hoodie-client-account/blob/master/helpers/clear-session.js#L7

In fetch.js, we always assume that state.session is an object here: https://github.com/hoodiehq/hoodie-client-account/blob/master/lib/fetch.js#L14, but after signout, it’s not an object, but undefined

Makes sense?

So we don’t even need to send a request if state.session is undefined, and can instead fail with UnauthenticatedError as described here: https://github.com/hoodiehq/hoodie-client-account#accountfetch

We don’t have a way to handle the errors yet, so for now you can do this:

var Promise = require('../helpers/promise')
// ...
function fetch (state, basePath, path) {
  if (!state.session) {
    var error = new Error('Not signed in')
    error.name = 'UnauthenticatedError'
    return Promise.reject(error)
  }
  return request({
    url: state.url + '/session/' + basePath.replace(/\./, '/'), // replace '.' in path with '/'
    method: 'GET',
// ...

I hope that’s not too confusing. Let me know if you have any farther questions. But also don’t worry too much, I'd suggest start a pull request, and we continue discussion there?

from hoodie-account-client.

ianstalter123 avatar ianstalter123 commented on July 17, 2024

Thanks for the explanation! So if I understand this issue should involve the error related calling fetch() when not authenticated.

from hoodie-account-client.

gr2m avatar gr2m commented on July 17, 2024

yes

from hoodie-account-client.

gr2m avatar gr2m commented on July 17, 2024

@ianstalter123 are you working on this one?

from hoodie-account-client.

ianstalter123 avatar ianstalter123 commented on July 17, 2024

Hey yes will try to do by tonight / send a pull request

Sent from my iPhone

On Dec 11, 2015, at 12:01 PM, Gregor Martynus [email protected] wrote:

@ianstalter123 are you working on this one?


Reply to this email directly or view it on GitHub.

from hoodie-account-client.

ianstalter123 avatar ianstalter123 commented on July 17, 2024

@gr2m
You want the error checking to be added to https://github.com/hoodiehq/hoodie-client-account/blob/master/lib/fetch.js#L14 right?

from hoodie-account-client.

gr2m avatar gr2m commented on July 17, 2024

Yeah I’d suggest even before the internals.fetchProperties call, check if state.session is set. And if it’s not, return a rejected Promise, similar to what we do here maybe? https://github.com/hoodiehq/hoodie-client-account/blob/master/lib/sign-in.js#L14

from hoodie-account-client.

ianstalter123 avatar ianstalter123 commented on July 17, 2024

pull request sent

2015-12-11 13:00 GMT-08:00 Gregor Martynus [email protected]:

Yeah I’d suggest even before the internals.fetchProperties call, check if
state.session is set. And if it’s not, return a rejected Promise, similar
to what we do here maybe?
https://github.com/hoodiehq/hoodie-client-account/blob/master/lib/sign-in.js#L14


Reply to this email directly or view it on GitHub
#18 (comment)
.

from hoodie-account-client.

gr2m avatar gr2m commented on July 17, 2024

done via e577566 & 4cb4e8c 👌

from hoodie-account-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.