Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 60430 invoked from network); 29 Nov 2010 21:35:00 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Nov 2010 21:35:00 -0000 Received: (qmail 17492 invoked by uid 500); 29 Nov 2010 21:34:59 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 17431 invoked by uid 500); 29 Nov 2010 21:34:59 -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 17415 invoked by uid 99); 29 Nov 2010 21:34:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Nov 2010 21:34:59 +0000 X-ASF-Spam-Status: No, hits=4.7 required=10.0 tests=FREEMAIL_FROM,FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of th4ngnh0c@gmail.com designates 209.85.161.180 as permitted sender) Received: from [209.85.161.180] (HELO mail-gx0-f180.google.com) (209.85.161.180) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Nov 2010 21:34:52 +0000 Received: by gxk19 with SMTP id 19so2508767gxk.11 for ; Mon, 29 Nov 2010 13:34:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=BIku/7IYjb6qbCuHYgYodMm2MKAxxrGHEVT9D/DiO4c=; b=e9GV6ng/ks+rSwlCR7v7L/TZITVXZFXMmGs0+dII0NrlbQ0fPFQDgSvevoiUIalNXi RpEhTwszeg/T5fOSSr1WYtlO7LR9gS93S5WKTQx4a6G9IpzaeZdyFDbIT36C9x8QWq1V P6gQcwQL/UZLDfUSwcxsaljuTBJMAqIEy7hm8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=xpPwvC1NQmxUih0NCl+IKGjG2CPBafpGHGisKEp/Eav4WBGr82I1KdMy1xg8VG9MpA c3PRBbX1TJROoh5OcR16n7zQ5C7MSbqO2OmscELypJDg5jrzcijIw8omWwADxIZFASbt T6QVZnhk055gvGLoncixWNrGBoQ5JkR1Y/Egg= MIME-Version: 1.0 Received: by 10.42.172.8 with SMTP id l8mr1818296icz.482.1291066471484; Mon, 29 Nov 2010 13:34:31 -0800 (PST) Received: by 10.42.172.129 with HTTP; Mon, 29 Nov 2010 13:34:31 -0800 (PST) In-Reply-To: References: Date: Mon, 29 Nov 2010 16:34:31 -0500 Message-ID: Subject: Re: $.couch.login(options); From: Duc Phan To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=90e6ba6e8f686a0d9e049637d67e --90e6ba6e8f686a0d9e049637d67e Content-Type: text/plain; charset=ISO-8859-1 Hi Alan, Thanks again for your help. Please excuse my lack of knowledge on these topics since I am new to JQuery + CouchDB. I have attempted to get the result from the login and failed. I have tried to several methods such as: 1. $.couch.login({name:"USERNAME" ,password:"PASSWORD"},{ success: function(result){ alert(result)}}); 2. $.couch.login({name:"USERNAME" ,password:"PASSWORD"}, success: function(result){ alert(result)}); 3. $.couch.login({name:"USERNAME" ,password:"PASSWORD"},{ success: function(result){ alert(result.value)}}); 4. $.couch.login({name:"USERNAME" ,password:"PASSWORD"},{ success: function(result){ alert(result.userCtx)}}); 5. $.couch.login({name:"USERNAME" ,password:"PASSWORD"},{ success: function(result){ alert(result.value.userCtx)}}); I must be missing something and I cannot figure out what it is. Again, I really appreciate your time and effort. -D On Mon, Nov 29, 2010 at 3:35 PM, Alan Plante wrote: > If you want the login result, you need to pass in a success and/or error > function with the object you pass to the login method. You can't get the > login result the way you're doing it. If you look at the code in the login > method, it makes an XHR call which is asynchronous. When it returns, if > you've specified a sucess/error function it will call it. That's how you > need to get the result. > > Wrt session method, I've never used it but if you look at the code, you > need > to pass in a success and/or error function and you don't need to pass in > name/password. > > I can't recommend enough stepping into those functions from your code just > so you not only get comfortable with debugging but you'll also get a better > feel for what the various functions require of callers. > > Hope this helps, > > Al > > On Mon, Nov 29, 2010 at 1:52 PM, Duc Phan wrote: > > > Hello again, > > > > I was able to log in from my couchapp using > > $.couch.login({name:"USERNAME",password:"PASSWORD"}); > > It seemed like I was able to login successfully but I get undefined as > > result when I try to pull up the session info. > > > > Here is a code segment of what I did. > > > > $db = $.couch.db("mydb"); > > var loginResult = $.couch.login({name:"USERNAME",password:"PASSWORD"}); > > var session = $.couch.session({name:"USERNAME",password:"PASSWORD"}); > > > > document.write(loginResult); > > document.write(session); > > > > And, I got undefined undefined as the results for both of them. > > Did I miss something ? I tried $.couch.session.(); and received the same > > result, undefined. > > > > Again, thanks for all your help. > > > > -D > > > > On Mon, Nov 29, 2010 at 10:07 AM, Duc Phan wrote: > > > > > Thank you so much for your responses. I will play with it now and > update > > > the results. > > > > > > -D > > > > > > > > > On Mon, Nov 29, 2010 at 9:52 AM, Alan Plante > >wrote: > > > > > >> Typically the login name and password are coming from a login > form/input > > >> controls of some sort, with values entered by the user, so the name > and > > >> password are not hardcoded in your code. So, would be something like: > > >> $.couch.login( {name:$("#userField").val(), > > >> password:$("#pwdField").val()}); > > >> > > >> Al > > >> > > >> On Mon, Nov 29, 2010 at 9:39 AM, Duc Phan > wrote: > > >> > > >> > Hi Allan, > > >> > > > >> > I still don't understand exactly how to pass in an object with a > name > > >> and > > >> > password property. > > >> > > > >> > The exact syntax in jquery.couch api for login is: > > >> > $.couch.login(options)say my created account is: jdoe/foo. > > >> > > > >> > do I do this? $.couch.login( {name:"jdoe", password:"foo"}); > > >> ??? > > >> > > > >> > And another question I have is...if that is how I login in couchapp > > >> using > > >> > jquery.couch . How do I protect my account login from > > >> > people doing view/Source? > > >> > > > >> > Thank you so much for your help. > > >> > > > >> > Best Regards, > > >> > D > > >> > > > >> > On Sun, Nov 28, 2010 at 6:39 PM, Alan Plante > > > >> > wrote: > > >> > > > >> > > Take a look in jquery.couch.js, located in > >> > > loc>/share/couchdb/www/script/jquery.couch.js (on Windows anyway, > > >> maybe > > >> > > somewhere else on Linux?). Another way to see what's going on in > > >> there > > >> > is > > >> > > to set a breakpoint and step into it in Firebug (assuming you're > on > > >> FFX; > > >> > > I'm > > >> > > sure there are similar tools on IE and Chrome). Login method > takes > > an > > >> > > object with a name and password property, so {name:"jdoe", > > >> > password:"foo"}. > > >> > > It also takes an optional success(response) and/or > > >> error(requestStatus, > > >> > > responseError, responseReason) function. > > >> > > > > >> > > Hope this helps, > > >> > > > > >> > > Al > > >> > > > > >> > > On Sun, Nov 28, 2010 at 4:26 PM, Duc Phan > > >> wrote: > > >> > > > > >> > > > Hello all, > > >> > > > > > >> > > > Can someone please explain to me what do I need to pass in as > the > > >> > > parameter > > >> > > > to log in from couchapp via jquery. > > >> > > > > > >> > > > For example I have an admin account name "John" "Doe". > > >> > > > What is the exact syntax to login and create a session in my > > >> couchApp. > > >> > > > > > >> > > > Thanks in advance. > > >> > > > > > >> > > > > >> > > > > >> > > > > >> > > > >> > > > > > > > > > --90e6ba6e8f686a0d9e049637d67e--