WOW Hold On!!
this is what i made form what I learned from teh tutrial, I created a EOModel called UsersModel and there I create an entity called Users which contains the follwoing atributes
lastName varchar(20) name varchar(20) userid int PK admin_privilege_key int password varchar(20)
so what im planing its to give the last atribute a valor of 1 or 0 depending if its admin or client respectlyvzly I generated the EO which has the accessors.
I was thinkin in make a WO called login with a form with username(which it will be the id) and the password so form there to the session. Im assuming that I have some data already in the db.(at least an admin and a client, for tests purposes )
so if its an admin it will open a new page (wo) which will have (for now) an insert user, and all its attributes. and display all the users or an specified user. and if its a client then... well i dunno what to display so far for the client.
What im having problem in understandin its about the EOEditingContex, like WTH is that, i have something in my mind i just need to assimilate it. and well I wanna get the user who is loggin from the database to see if its a admin or client. so i think i must use this valueForKey( String key) and this should be in the Session.java no? just that something is telling me I must use the EOEditingcontexts no?
Gus
On Mar 14, 2008, at 9: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());
Chuck
--
Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/practical_webobjects
|