On 14-Mar-08, at 10:58 PM, Chuck Hill wrote:


On Mar 14, 2008, at 6:46 PM, Gustavo Pizano wrote:

Hello, well after doing the tutorial I will try to do simple things, like log into a system, and depending if the user is Client or Admin it will show diferents webpages, Im planing this to start having a better understanding of the "how does it work". SO lets say I have a DB with users and privileges, so at the login page will log on as client or admin, I was reading how to schive this simple thing, but hadn't been able to figure it out. As far as I understadn I must delegate this to the EOF with some especial class and special operation, just I can't find it.

or.. if there is other easier way to do it with WO/EO, then can I get some help, even don;t telling me the "how" otherwise it will take the "magic" away, but the "where" can i find info.

Here is something to get you thinking:

String userID;  // From  your login page
String password;   // From  your login page
Session session = (Session)session();

// You need to write session.setUser() and User.authenticatedUserFromCredentials() session .setUser (User .authenticatedUserFromCredentials(session.defaultEditingContext(), userID, password);
if (person == null) {
   // Handle failure to log in, then
   return context().page();
}

// You need to define ADMIN_PRIVILEGE_KEY and write Privilege.privilegeWithKey() Privilege adminPrivilege = Privilege.privilegeWithKey(session.defaultEditingContext(, Privilege.ADMIN_PRIVILEGE_KEY);

if (session.user().privileges().containsObject(adminPrivilege)) {
   return pageWithName(AdminHomePage.class.getName());
}

return pageWithName(HomePage.class.getName());

If you are having a problem actually figuring out how to fetch and authenticate the User, I enhanced the wiki with some simple examples of the different ways to qualify and create a fetch in EOF:

<http://wiki.objectstyle.org/confluence/display/WO/Programming__WebObjects-EOF-Using+EOF-Fetching >

;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site:   http://codeferous.com
blog: http://davidleber.net
profile: http://www.linkedin.com/in/davidleber
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to