Re: simple database login
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.