X-Git-Url: http://git.onelab.eu/?p=myops.git;a=blobdiff_plain;f=web%2Fquery%2Fvendor%2Fcouchapp%2Fevently%2Fprofile%2FloggedIn.js;fp=web%2Fquery%2Fvendor%2Fcouchapp%2Fevently%2Fprofile%2FloggedIn.js;h=b0c566a1483795995f72851d9c3b3f261e558212;hp=0000000000000000000000000000000000000000;hb=85070b3d456667f238051af1a2f1f2a0c12300ab;hpb=607f0e13927eb18075c375fa9ba5527da4fcbb44 diff --git a/web/query/vendor/couchapp/evently/profile/loggedIn.js b/web/query/vendor/couchapp/evently/profile/loggedIn.js new file mode 100644 index 0000000..b0c566a --- /dev/null +++ b/web/query/vendor/couchapp/evently/profile/loggedIn.js @@ -0,0 +1,21 @@ +function(e, r) { + var userCtx = r.userCtx; + var widget = $(this); + // load the profile from the user doc + var db = $.couch.db(r.info.authentication_db); + var userDocId = "org.couchdb.user:"+userCtx.name; + db.openDoc(userDocId, { + success : function(userDoc) { + var profile = userDoc["couch.app.profile"]; + if (profile) { + // we copy the name to the profile so it can be used later + // without publishing the entire userdoc (roles, pass, etc) + profile.name = userDoc.name; + $$(widget).profile = profile; + widget.trigger("profileReady", [profile]); + } else { + widget.trigger("noProfile", [userCtx]); + } + } + }); +} \ No newline at end of file