javascript - Strategy to retrieve the current user -
i'm looking classy strategy retrieve current user information emberjs (and ember-data).
currently, following :
my api responds /users/me
current user.
in adapter, when retrieved object id isn't 1 i'm hoping for, add real_id
id (the user's id in database) , replace real returned id i'm expecting.
so when adapter has "me" user's id, server returns 1, following json :
{"real_id": 1, "id": "me"}
this works. i'm not big fan, , i'd avoid mush possible change default content of adapter.
do use strategy ? recommend ?
i use controller app.currentusercontroller
this.
app.currentusercontroller = ember.objectcontroller.extend({ content: null, retrievecurrentuser: function() { var controller = this; ember.$.getjson('/users/me', function(data) { app.store.load(app.user, data); var currentuser = app.store.find(data.id); controller.set('content', currentuser); }); } });
Comments
Post a Comment