Comments (10)
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.
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.
Thanks for the explanation! So if I understand this issue should involve the error related calling fetch() when not authenticated.
from hoodie-account-client.
yes
from hoodie-account-client.
@ianstalter123 are you working on this one?
from hoodie-account-client.
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.
@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.
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.
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.
from hoodie-account-client.
Related Issues (20)
- 💯 test coverage
- when fetching account from remote succeeds, we should unset `session.invalid` HOT 1
- An in-range update of browserify is breaking the build 🚨 HOT 1
- Prevent signIn/Up if already signed in (session exists)
- signIn() does not store the roles property
- account.signOut while offline HOT 7
- Question: why does sign in omit the session information? HOT 2
- An in-range update of uglify-js is breaking the build 🚨 HOT 66
- An in-range update of semantic-release is breaking the build 🚨 HOT 1
- An in-range update of semantic-release is breaking the build 🚨 HOT 1
- An in-range update of semantic-release is breaking the build 🚨 HOT 34
- An in-range update of lodash is breaking the build 🚨 HOT 4
- The automated release is failing 🚨
- An in-range update of nock is breaking the build 🚨 HOT 6
- An in-range update of tap-min is breaking the build 🚨 HOT 1
- An in-range update of before-after-hook is breaking the build 🚨 HOT 5
- An in-range update of npm-run-all is breaking the build 🚨 HOT 2
- An in-range update of tape is breaking the build 🚨 HOT 9
- An in-range update of rimraf is breaking the build 🚨 HOT 3
- An in-range update of browserify is breaking the build 🚨 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hoodie-account-client.