incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Plante <alan.pla...@gmail.com>
Subject Re: $.couch.login(options);
Date Mon, 29 Nov 2010 21:46:55 GMT
The success and error functions need to be in the same object as the user
and pwd fields:
{
    name:"USERNAME",
    password:"PASSWORD",
    success: function(resp){
       alert(resp);
    },
    error: function(status, error, reason){
        alert("Status: " + status + " Error: " + error + " Reason: " +
reason);
    }
}

On Mon, Nov 29, 2010 at 4:34 PM, Duc Phan <th4ngnh0c@gmail.com> wrote:

> 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 <alan.plante@gmail.com>
> 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 <th4ngnh0c@gmail.com> 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 <th4ngnh0c@gmail.com>
> 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 <alan.plante@gmail.com
> > > >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 <th4ngnh0c@gmail.com>
> > 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 <
> alan.plante@gmail.com
> > >
> > > >> > wrote:
> > > >> >
> > > >> > > Take a look in jquery.couch.js, located in <couch install
> > > >> > > 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 <th4ngnh0c@gmail.com>
> > > >> 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.
> > > >> > > >
> > > >> > >
> > > >> > >
> > > >> > >
> > > >> >
> > > >>
> > > >
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message