Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E47FD9EB2 for ; Sun, 23 Oct 2011 13:55:46 +0000 (UTC) Received: (qmail 2246 invoked by uid 500); 23 Oct 2011 13:55:45 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 2212 invoked by uid 500); 23 Oct 2011 13:55:45 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 2204 invoked by uid 99); 23 Oct 2011 13:55:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Oct 2011 13:55:45 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.216.173] (HELO mail-qy0-f173.google.com) (209.85.216.173) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Oct 2011 13:55:39 +0000 Received: by qyk10 with SMTP id 10so1755828qyk.11 for ; Sun, 23 Oct 2011 06:55:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.68.167 with SMTP id v39mr4345468qci.66.1319378118018; Sun, 23 Oct 2011 06:55:18 -0700 (PDT) Received: by 10.229.1.234 with HTTP; Sun, 23 Oct 2011 06:55:17 -0700 (PDT) In-Reply-To: References: Date: Sun, 23 Oct 2011 14:55:17 +0100 Message-ID: Subject: Re: looking for couchapp examples for managing user authentification From: Dale Harvey To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0016e64f829c0c85df04aff7a858 X-Virus-Checked: Checked by ClamAV on apache.org --0016e64f829c0c85df04aff7a858 Content-Type: text/plain; charset=ISO-8859-1 futon is often a good example of how to do some things GET http://127.0.0.1:5984/_session {"ok":true,"userCtx":{"name":"dale","roles":["_admin"]},"info":{"authentication_db":"_users","authentication_handlers":["oauth","cookie","default"],"authenticated":"cookie"}} Cheers Dale On 23 October 2011 12:08, Alexander Gabriel wrote: > Great, thank you Benoit. > > Are there examples of entire applications, where I can see how the username > is fetched after logging in and opening a new html-page? > > Alex > > > > 2011/10/23 Benoit Chesneau > > > 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 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 > > > > > > --0016e64f829c0c85df04aff7a858--