Add scripts to create myops-getqueryview:
[myops.git] / web / query / vendor / couchapp / evently / profile / loggedIn.js
diff --git a/web/query/vendor/couchapp/evently/profile/loggedIn.js b/web/query/vendor/couchapp/evently/profile/loggedIn.js
new file mode 100644 (file)
index 0000000..b0c566a
--- /dev/null
@@ -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