fenichelar/ember-simple-auth-token

can't do a store query inside of sessionStore?

Closed this issue · 0 comments

Trying to fetch the "current user" from my backend. I have a route which sends the token (and stores a copy of it in the database as a string), and then I extend the session service and add a currentUser property to it.

currentUser: Ember.computed('isAuthenticated', function() {
    if (this.get('isAuthenticated')) {
     const promise = this.get('store').queryRecord('user', {});
     return DS.PromiseObject.create({ promise: promise });
    }
  })

When I send a post to /token, I get back the token and send get request to /users which uses the token stored in the authorization header to find the user information and send it back. I then create a promise object and render the result back to my template. However the queryRecord gives me the follow error:

13:16:13.568 authorize@http://localhost:4200/assets/vendor.js:93557:9
ajaxOptions/hash.beforeSend@http://localhost:4200/assets/vendor.js:93258:9
.ajax@http://localhost:4200/assets/vendor.js:8925:6
_ajaxRequest@http://localhost:4200/assets/vendor.js:86385:7
ajax/<@http://localhost:4200/assets/vendor.js:86375:9
initializePromise@http://localhost:4200/assets/vendor.js:63982:7
Promise@http://localhost:4200/assets/vendor.js:65834:7
ajax@http://localhost:4200/assets/vendor.js:86337:14
queryRecord@http://localhost:4200/assets/vendor.js:85925:16
_queryRecord@http://localhost:4200/assets/vendor.js:81849:19
queryRecord@http://localhost:4200/assets/vendor.js:82953:72
exports.default<.currentUser<@http://localhost:4200/assets/theoryfall.js:1960:23
ComputedPropertyPrototype.get@http://localhost:4200/assets/vendor.js:25339:15
get@http://localhost:4200/assets/vendor.js:30939:14
_getPath@http://localhost:4200/assets/vendor.js:30961:13
get@http://localhost:4200/assets/vendor.js:30935:14
getProperties@http://localhost:4200/assets/vendor.js:25634:31
generateComputedWithProperties/</computedFunc<@http://localhost:4200/assets/vendor.js:25646:35
ComputedPropertyPrototype.get@http://localhost:4200/assets/vendor.js:25339:15
get@http://localhost:4200/assets/vendor.js:30939:14
exports.default<.compute@http://localhost:4200/assets/vendor.js:32036:16
BasicStream.prototype.value@http://localhost:4200/assets/vendor.js:32229:22
read@http://localhost:4200/assets/vendor.js:32596:14
getValue@http://localhost:4200/assets/vendor.js:19114:17
range@http://localhost:4200/assets/vendor.js:58839:13
AlwaysDirtyVisitor.content@http://localhost:4200/assets/vendor.js:59231:7
RenderResult.prototype.populateNodes@http://localhost:4200/assets/vendor.js:59629:11
RenderResult.prototype.render@http://localhost:4200/assets/vendor.js:59562:5
render@http://localhost:4200/assets/vendor.js:59372:5
yieldTemplate/<@http://localhost:4200/assets/vendor.js:58130:7
ifUnless@http://localhost:4200/assets/vendor.js:18190:9
unlessHelper@http://localhost:4200/assets/vendor.js:18174:12
BuiltInHelperStream<.compute@http://localhost:4200/assets/vendor.js:22328:14
BasicStream.prototype.value@http://localhost:4200/assets/vendor.js:32229:22
invokeHelper@http://localhost:4200/assets/vendor.js:19187:21
continueBlock/<@http://localhost:4200/assets/vendor.js:58508:14
renderAndCleanup@http://localhost:4200/assets/vendor.js:60234:18
hostBlock@http://localhost:4200/assets/vendor.js:58514:5
continueBlock@http://localhost:4200/assets/vendor.js:58506:5
block@http://localhost:4200/assets/vendor.js:58502:5
AlwaysDirtyVisitor.block@http://localhost:4200/assets/vendor.js:59196:7
RenderResult.prototype.populateNodes@http://localhost:4200/assets/vendor.js:59625:11
RenderResult.prototype.render@http://localhost:4200/assets/vendor.js:59562:5
render@http://localhost:4200/assets/vendor.js:59372:5
Block.prototype._firstRender/<@http://localhost:4200/assets/vendor.js:60199:7
renderAndCleanup@http://localhost:4200/assets/vendor.js:60234:18
Block.prototype._firstRender@http://localhost:4200/assets/vendor.js:60196:5
Block.prototype.invoke@http://localhost:4200/assets/vendor.js:60174:7
yieldKeyword@http://localhost:4200/assets/vendor.js:21599:7
handleKeyword@http://localhost:4200/assets/vendor.js:58551:14
handleRedirect@http://localhost:4200/assets/vendor.js:58537:9
inline@http://localhost:4200/assets/vendor.js:58680:9
AlwaysDirtyVisitor.content@http://localhost:4200/assets/vendor.js:59216:9
RenderResult.prototype.populateNodes@http://localhost:4200/assets/vendor.js:59629:11
RenderResult.prototype.render@http://localhost:4200/assets/vendor.js:59562:5
render@http://localhost:4200/assets/vendor.js:59372:5
Block.prototype._firstRender/<@http://localhost:4200/assets/vendor.js:60199:7
renderAndCleanup@http://localhost:4200/assets/vendor.js:60234:18
Block.prototype._firstRender@http://localhost:4200/assets/vendor.js:60196:5
Block.prototype.invoke@http://localhost:4200/assets/vendor.js:60174:7
ComponentNodeManager_render_instrument@http://localhost:4200/assets/vendor.js:21883:9
instrument@http://localhost:4200/assets/vendor.js:22602:14
ComponentNodeManager_render@http://localhost:4200/assets/vendor.js:21875:12
componentHook@http://localhost:4200/assets/vendor.js:18696:7
handleRedirect@http://localhost:4200/assets/vendor.js:58526:11
range@http://localhost:4200/assets/vendor.js:58835:9
AlwaysDirtyVisitor.content@http://localhost:4200/assets/vendor.js:59231:7
RenderResult.prototype.populateNodes@http://localhost:4200/assets/vendor.js:59629:11
RenderResult.prototype.render@http://localhost:4200/assets/vendor.js:59562:5
render@http://localhost:4200/assets/vendor.js:59372:5
Block.prototype._firstRender/<@http://localhost:4200/assets/vendor.js:60199:7
renderAndCleanup@http://localhost:4200/assets/vendor.js:60234:18
Block.prototype._firstRender@http://localhost:4200/assets/vendor.js:60196:5
Block.prototype.invoke@http://localhost:4200/assets/vendor.js:60174:7
yieldKeyword@http://localhost:4200/assets/vendor.js:21599:7
handleKeyword@http://localhost:4200/assets/vendor.js:58551:14
handleRedirect@http://localhost:4200/assets/vendor.js:58537:9
inline@http://localhost:4200/assets/vendor.js:58680:9
AlwaysDirtyVisitor.content@http://localhost:4200/assets/vendor.js:59216:9
RenderResult.prototype.populateNodes@http://localhost:4200/assets/vendor.js:59629:11
RenderResult.prototype.render@http://localhost:4200/assets/vendor.js:59562:5
render@http://localhost:4200/assets/vendor.js:59372:5
Block.prototype._firstRender/<@http://localhost:4200/assets/vendor.js:60199:7
renderAndCleanup@http://localhost:4200/assets/vendor.js:60234:18
Block.prototype._firstRender@http://localhost:4200/assets/vendor.js:60196:5
Block.prototype.invoke@http://localhost:4200/assets/vendor.js:60174:7
ViewNodeManager_render_instrument@http://localhost:4200/assets/vendor.js:22146:9
instrument@http://localhost:4200/assets/vendor.js:22602:14
ViewNodeManager_render@http://localhost:4200/assets/vendor.js:22130:12
exports.default.render@http://localhost:4200/assets/vendor.js:20875:7
handleKeyword@http://localhost:4200/assets/vendor.js:58590:9
handleRedirect@http://localhost:4200/assets/vendor.js:58537:9
inline@http://localhost:4200/assets/vendor.js:58680:9
AlwaysDirtyVisitor.content@http://localhost:4200/assets/vendor.js:59216:9
RenderResult.prototype.populateNodes@http://localhost:4200/assets/vendor.js:59629:11
RenderResult.prototype.render@http://localhost:4200/assets/vendor.js:59562:5
render@http://localhost:4200/assets/vendor.js:59372:5
Block.prototype._firstRender/<@http://localhost:4200/assets/vendor.js:60199:7
renderAndCleanup@http://localhost:4200/assets/vendor.js:60234:18
Block.prototype._firstRender@http://localhost:4200/assets/vendor.js:60196:5
Block.prototype.invoke@http://localhost:4200/assets/vendor.js:60174:7
ViewNodeManager_render_instrument@http://localhost:4200/assets/vendor.js:22146:9
instrument@http://localhost:4200/assets/vendor.js:22602:14
ViewNodeManager_render@http://localhost:4200/assets/vendor.js:22130:12
renderHTMLBarsBlock@http://localhost:4200/assets/vendor.js:22870:5
TemplateRenderingSupport<.renderBlock@http://localhost:4200/assets/vendor.js:52551:14
Renderer_prerenderTopLevelView@http://localhost:4200/assets/vendor.js:33908:5
Renderer_renderTopLevelView@http://localhost:4200/assets/vendor.js:33917:7
Queue.prototype.invoke@http://localhost:4200/assets/vendor.js:10457:9
Queue.prototype.flush@http://localhost:4200/assets/vendor.js:10523:11
DeferredActionQueues.prototype.flush@http://localhost:4200/assets/vendor.js:10331:11
Backburner.prototype.end@http://localhost:4200/assets/vendor.js:10686:9
Backburner.prototype.run@http://localhost:4200/assets/vendor.js:10808:13
Backburner.prototype.join@http://localhost:4200/assets/vendor.js:10828:16
run.join@http://localhost:4200/assets/vendor.js:31307:12
run.bind/<@http://localhost:4200/assets/vendor.js:31370:14
jQuery.Callbacks/fire@http://localhost:4200/assets/vendor.js:3498:11
jQuery.Callbacks/self.fireWith@http://localhost:4200/assets/vendor.js:3628:7
.ready@http://localhost:4200/assets/vendor.js:3847:3
completed@http://localhost:4200/assets/vendor.js:3863:2
1 vendor.js:42222:9
onerrorDefault() vendor.js:42222
exports.default.trigger() vendor.js:64602
Promise.prototype._onError/<() vendor.js:65853
Queue.prototype.invoke() vendor.js:10459
Queue.prototype.flush() vendor.js:10523
DeferredActionQueues.prototype.flush() vendor.js:10331
Backburner.prototype.end() vendor.js:10686
Backburner.prototype.run() vendor.js:10808
Backburner.prototype.join() vendor.js:10828
run.join() vendor.js:31307
run.bind/<() vendor.js:31370
jQuery.Callbacks/fire() vendor.js:3498
jQuery.Callbacks/self.fireWith() vendor.js:3628
.ready() vendor.js:3847
completed() vendor.js:3863

and doesn't render anything back.