Trouble Building Login Form Using REST api

26 views
Skip to first unread message

Eric Dorman

unread,
Nov 25, 2009, 3:25:47 PM11/25/09
to NextDB Users
Hey guys,

Does anyone know how I'd go about building out a Login form with the
REST api?

I already know how to build forms that users can fill in,but isn't a
Login Form harder to accomplish?

I have given feedback on REST and I think it's amazing.

Thanks & God Bless,
Eric Dorman

Brent Hamby

unread,
Nov 25, 2009, 3:48:15 PM11/25/09
to nextd...@googlegroups.com
Hi Eric,

Why wouldn't you use the form builder API for building a form?

Building a login form with the JS API is really simple, you could either use the Form Builder API, or just do it from scratch since there are only two fields:

1. make a query called LOGIN that takes two parameters, e.g. login and password
2. make a simple form with HTML
3. register a click handler on the 'login' button to call a "login" function that looks like this:

function login(){
   var query = new net.nextdb.Query("LOGIN");
   query.setParameters({"login": document.getElementById("login"),"password":$F("password")});
   conn.executeQuery(query,
   function(user,error){
      if(error){
         // tell user there was an error
      } else {
         if(user.length==1){
            // do whatever you do when they login 
         }else{
            // tell user invalid login
         }
      }
   });
}





--

You received this message because you are subscribed to the Google Groups "NextDB Users" group.
To post to this group, send email to nextd...@googlegroups.com.
To unsubscribe from this group, send email to nextdb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nextdb-user?hl=en.





--
Brent Hamby
brent...@gmail.com
mobile: 510.421.5232
---The content of this email is confidential.---

Eric Dorman

unread,
Nov 25, 2009, 4:51:04 PM11/25/09
to NextDB Users
Hey Brent,

After I posted this I realized just what you said above.

So I built my form and I generated the code from the Code Help Tab and
it works great.

If you don't mind me asking,but why did you guys add the Code Help
Feature were we can generate our code easily then writing it out
ourselves?

I am just so used to writing the long lines of code to get a form to
work with Nextdb and this new feature is a life savor although I do
still hope I can gain some knowledge of and learn how to make these
forms myself with little coding needed.

Thanks & God Bless,
Eric Dorman

> > nextdb-user...@googlegroups.com<nextdb-user%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nextdb-user?hl=en.
>
> --
> Brent Hamby
> brentha...@gmail.com

geoffrey hendrey

unread,
Nov 25, 2009, 6:42:51 PM11/25/09
to nextd...@googlegroups.com
Hey Eric,

Definitely go with what brent says. It's the best way to do it.

I'm working on some REST support for queries that will help in getting automatically generated JS-API forms. It works with the JS-API in a complementary way. When I have deployed it, you can access your queries like this (for a query named LOGIN with parameters named "uname" and "pwd"):

.../account/db/q/LOGIN?uname=bob&pwd=xxxxxx

or you can also access them like this (more of a REST-style that doesn't user query parameters):

.../account/db/q/LOGIN/uname/bob/pwd/xxxxxxx

Here is how you will be able to automatically get a JavaScript form that brent mentioned for submitting a query (sort of automatic JS-API form generation):

.../account/db/q/LOGIN/form

I'm also working on a system that will let you load and store cookies. So let's say you want to log someone in once, and then automatically pass their username and password as encrypted cookies. When you login the user, you simply state that you want the uname and pwd to be set as encrypted cookies. It will look something like this:

.../account/db/q/LOGIN/uname;set-cookie/bob/pwd;set-cookie/xxxxxxx

Then subsequent queries (ones that would access private user data) can grab the encrypted cookies from the HTTP Session as though the user had entered them himself. So let's say we have a query named "GET_SECRETS":


.../account/db/q/GET_SECRETS/uname;get-cookie//pwd;get-cookie//

In the URL above, notice that the space where you would ordinarily pass the username and password is left blank --- that's because nextdb will fill them in by getting the encrypted cookies from the HTTP session.

-geoff





--

You received this message because you are subscribed to the Google Groups "NextDB Users" group.
To post to this group, send email to nextd...@googlegroups.com.
To unsubscribe from this group, send email to nextdb-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nextdb-user?hl=en.





--
http://nextdb.net - RESTful Relational Database
http://www.nextdb.net/wiki/en/REST
Reply all
Reply to author
Forward
0 new messages