• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: simple database login
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple database login


  • Subject: Re: simple database login
  • From: Chuck Hill <email@hidden>
  • Date: Tue, 11 Mar 2003 11:05:09 -0800

I'm assuming here that you have an EO named User, with two attributes of
userID and password.  If you have used something else you will need to
change the names.  Add this method to User.java:


public static boolean canAuthenticate(EOEditingContext ec,
                                      String aUserID,
                                      String aPassword)
{
    User authenticatedUser = null;
    try {
        NSDictionary authDictionary =
           new NSDictionary( new Object[] { aUserID, aPassword},
                             new Object[] { "userID", "password"});
        authenticatedUser = (User)
            EOUtilities.objectMatchingValues(ec,
                                             "User",
                                             authDictionary);
    }
    catch (EOObjectNotAvailableException e) {
        // bad user id / password
    }
    catch (EOUtilities.MoreThanOneException e) {
        // Gadzooks Scoob!  The DB is hooped!
    }

    return authenticatedUser != null;
}


Then in your login form:

    if (User.canAuthenticate(session().defaultEditingContext(),
                             enteredUserID, enteredPassword)
    etc.

You can also change the above code to return null or the authenticated user
and handle it like that too.



Chuck



At 01:48 PM 11/03/2003 -0500, Kenny Sabarese wrote:
>>>>
how to validate it against the database

On Tuesday, March 11, 2003, at 12:09  PM, Chuck Hill wrote:

Are you asking how to make a login form, or how to validate a user name /
password pair?


Chuck


At 10:24 AM 11/03/2003 -0500, Kenny Sabarese wrote:
i'm beginning to get frustrated, i guess this is normal for someone new
to an extremely strange and challenging environment.

all of the provided examples that have login pages seem to be extremely
too complex that i would be able to borrow the code into one of my
projects. i know that in most other languages i can do a login against
a username and password stored in a database in about 5 lines or less.

can someone give me some hints on how to pull this off from scratch?

----------------------
Kenny Sabarese
email@hidden
http://kenny.sabarese.net
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


--

Chuck Hill                                 email@hidden
Global Village Consulting Inc.             http://www.global-village.net


----------------------
Kenny Sabarese
email@hidden
http://kenny.sabarese.net


<<<<


--

Chuck Hill                                 email@hidden
Global Village Consulting Inc.             http://www.global-village.net
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: simple database login (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: [WO45] Problem with a new EOQualifier subclass in Java
  • Next by Date: Re: WebObjects Developer and Deployment on Mac OS X Server
  • Previous by thread: Re: simple database login
  • Next by thread: Re: simple database login
  • Index(es):
    • Date
    • Thread