Cheong:

your login direct action could look like this:

public WOActionResults loginAction() {
  String group = request().formValueForKey( "group" );
  if ( /* group is null or not a valid group */ ) {
    return pageWithName( "SomeErrorPage" );
  }
  ((Session)session()).setGroup( group );

//have Main look in the session to get the group, and set everything up from there
  //this assumes Main is your login page
  return pageWithName( "Main" );
}

Then you are only getting one form value outside of the RR loop, and leave DA land for component actions when you return pageWithName().

My suggestion for the cookie was for storing the group in case of session timeout so you could bring the user back to the correct login page. If they have cookies disabled, everything should work except the session timeout return - that would have to go to a generic page.

The redirect would happen as an apache redirect:

RedirectMatch temp "/login/(.*)" http://domain.com/cgi-bin/WebObjects/ App.woa/wa/login?group=$1

This would redirect http://domain.com/login/group_a to http:// domain.com/cgi-bin/WebObjects/App.woa/wa/login?group=group_a

Tobias

On Aug 15, 2007, at 5:05 AM, Cheong Hee (Datasonic) wrote:

Tobias

Thanks for the lead. And yes, this is WO app and with apache redirection. User will be required to log in via their own url for authentication and view their contents. e.g.: user from company A will log in through www.mydomain.com/ userCompanyA, which in turn redirects them to www.mydomain.com/cgi- bin/WebObjects/myAppA. user from company B will log in through www.mydomain.com/ userCompanyB, which in turn redirects them to www.mydomain.com/cgi- bin/WebObjects/myAppB.

Both are pointing to the same application - MyApp, but different instances and database. These are working fine, but I thought there must be a better way to maintain only one application MyApp, instead. If I understood you, the following is possible by setting the cookies: 'domain.com/group_a/' redirect to: 'domain.com/cgi-bin/WebObjects/ app.woa/wa/login?group=group_a'

This is a my dump question, i supposed: Rather than login.wo, how to set the url right when the first component to call is Main.wo? It will be great and I could then retrieve them using formValues or cookieValues from the r-r loop. And then initialize the database connection dictionary accordingly.

Also, is there any downside e.g. some of the browsers may block the cookies due to user setting?

Cheers

Cheong Hee


----- Original Message -----
From: Tobias Crawley
To: Cheong Hee (Datasonic)
Cc: webobjects-dev@lists.apple.com
Sent: Tuesday, August 14, 2007 8:18 PM
Subject: Re: Common application for different database users

Cheong:

Is this an application that requires the users to login to see any content? If so, I've handled this in an app by having a static login page for each group. The login page contains a hidden field that identifies the group, and each group has its own database. The login action uses the group identifier to look up group specific info (including the name of the group database) from a group wide database. The group's database is set in the session, then the login action verifies the user's credentials. Even if a user used another group's login page, they would still need a valid username and password for that group to access the content. Each group's login page was in a separate directory (domain.com/group_a/login, domain.com/group_b/login, etc. ), but after login, they all pointed to the same app path.

This wasn't a WO application, but if it was, I probably would have a apache redir rule to map: 'domain.com/group_a/' to: 'domain.com/ cgi-bin/WebObjects/app.woa/wa/login?group=group_a' which would return a component based login page. I would also set the selected group as a cookie, so I could send the user back to the proper login page on session expiration, or if the user accessed domain.com/.

I'm sure setting the database on the fly from the session is easily doable in WO, though I've never done it.

Of course, if your users are not required to log in to access the content, then not much of this is useful to your current situation.

Tobias

On Aug 13, 2007, at 11:16 PM, Cheong Hee (Datasonic) wrote:

I have the same application that is currently used by different group of users (or company). I did it in JavaMonitor and gave them different name for application instances and initialized them with few own parameters in
JavaMonitor.  So that when each group of them will access through:
www.mydomain.com/aaa after webserver redirection for group "aaa"
etc..
This made me maintains list of application instances.

The other option is to let user go to the common home page, and have a
selector to choose so that to differentiate the group of users.
But this could be an issue, as it means other groups/companies are exposed
to anyone who go to the common home page.

Is there any better way of design so that the same application could be used
to access their own database, while not to create list of different
application instances in JavaMonitor?

Cheers

Cheong Hee


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

This email sent to [EMAIL PROTECTED]


---
Tobias Crawley
[EMAIL PROTECTED]





---
Tobias Crawley
[EMAIL PROTECTED]



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
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