there are ex of code on github: https://github.com/couchapp/couchdb-login-jquery https://github.com/couchapp/example
enoit On Sunday, October 23, 2011, Alexander Gabriel <[email protected]> wrote: > Hi all > > This is surely a very basic beginners problem - I am biologist and only > starting to learn programming. It may well be a java script issue and have > nothing to do with couchdb. > > In my couchapp ( > http://barbalex.iriscouch.com/evab-ch_barbalex_evab/_design/evab/index.html > , https://github.com/barbalex/EvabMobile) every page needs to know the user > name as that is saved in every file. After logging in I get the user name > like this in every page: > > *User = ""; //use global variable to save user name in* > *$.couch.session({* > * success : function(r) {* > * userCtx = r.userCtx;* > * if (userCtx.name) {* > * //save user name in variable* > * User = userCtx.name;* > * } else {* > * //user is not logged in, present the login page* > * window.open(Pfad + "index.html", target="_self");* > * }* > * }* > *});* > > There probably are several problems here (for example using a global > variable, not using a dedicated function to fetch the username) which is > probably why this is bugging me - the variable "User" doesn't seem to return > the username correctly - sometimes it does, others it doesn't (even though > "GET http://barbalex.iriscouch.com/_session" returns " > {"ok":true,"userCtx":{"name":"z","roles":[]},"info":{"authentication_db":"_users","authentication_handlers" > :["oauth","cookie","default"],"authenticated":"cookie"}}"). I have spent a > while now on this problem and come to the point where I need a pointer. > > I don't expect you experts to teach me java script of course. It would be > great if you could point me to some couchapps I could look into to learn how > this (and other stuff) is done correctly. > > I looked into AndroidGrocerySync for Android. But it seems to be a native > app programmed in java. > > Your help is much appreciated! > > Alex >
