Re: infoglue login / logout / invalid login logic
astik <[email protected]>
| Newsgroups | gmane.comp.cms.infoglue.devel |
|---|---|
| Message-ID | <[email protected]> |
In fact, I changed my mind ...
Here are my repository properties :
loginUrl=ViewPage.action?siteNodeId=20
invalidLoginUrl=ViewPage.action?siteNodeId=20&invalidLogin=true
noAccessUrl=ViewPage.action?siteNodeId=21
I changed
org.infoglue.deliver.applications.actions.ExtranetLoginAction to
remove the final keyword
Here is my new ExtranetLoginAction class below.
One problem .. it only works for the master repository 'cause I don't
have the repository id ... for now it's enough for me =)
__
Romain
http://blog.astik.info
import java.net.URLEncoder;
import org.exolab.castor.jdo.Database;
import
org.infoglue.cms.controllers.kernel.impl.simple.CastorDatabaseService;
import org.infoglue.cms.entities.management.RepositoryVO;
import
org.infoglue.deliver.controllers.kernel.impl.simple.BaseDeliveryController
;
import
org.infoglue.deliver.controllers.kernel.impl.simple.RepositoryDeliveryController
;
public class ExtranetLoginAction extends
org.infoglue.deliver.applications.actions.ExtranetLoginAction {
private static final long serialVersionUID = -8955778935621676921L;
private String getRepositoryProperty(final String propertyName)
throws Exception {
RepositoryDeliveryController rdc =
RepositoryDeliveryController.getRepositoryDeliveryController();
Database db = CastorDatabaseService.getDatabase();
BaseDeliveryController.beginTransaction(db);
try {
RepositoryVO repositoryVo = rdc.getMasterRepository(db);
String invalidLogin = rdc.getExtraPropertyValue
(repositoryVo.getRepositoryId(), propertyName);
String returnAddress = this.getOriginalFullURL();
String url = invalidLogin + (invalidLogin.indexOf("?") > -1 ? "&" :
"?") + "returnAddress=" + URLEncoder.encode(returnAddress, "UTF-8");
return url;
} finally {
BaseDeliveryController.rollbackTransaction(db);
}
}
private void redirect(final String propertyName) throws Exception {
String invalidLoginUrl = getRepositoryProperty(propertyName);
String returnAddress = this.getOriginalFullURL();
String url = invalidLoginUrl + (invalidLoginUrl.indexOf("?") > -1 ?
"&" : "?") + "returnAddress=" + URLEncoder.encode(returnAddress,
"UTF-8");
this.getResponse().sendRedirect(url);
}
public String doAuthenticateUser() throws Exception {
String result = super.doAuthenticateUser();
if ("invalidLogin".equals(result)) {
redirect("invalidLoginUrl");
}
return NONE;
}
public String doNoAccess() throws Exception {
String result = super.doNoAccess();
if ("noAccess".equals(result)) {
redirect("noAccessUrl");
}
return NONE;
}
}
Le 4 sept. 2009 à 12:37, astik a écrit :
>
> Hi all,
> I'm having some issues with handling login logic ... I don't know if
> I'm doing it well or not =/
> I d'ont want my login form to be the default infoglue one, but i want
> a login form into my website.
>
> The url is ViewPage.action?siteNodeId=20 defined into repository
> properties :
> loginUrl=ViewPage.action?siteNodeId=20
>
> It works great for login.
> For logout, i just have to give the returnAddress in url parameter and
> it works too.
>
> Problem is with invalid login.
>
> Here is what happen :
> - user tries to access a protected page
> - ViewPageFilter forwards to ViewPageAction
> -ViewPageAction call handleExtranetLogic method which uses
> getRedirectUrl method
> - getRedirectUrl method load the url from the authenticationModule and
> is overload by the repositoryLoginUrl
> - login form displayed on loginUrl
> - user submit login form, the form action is : ExtranetLogin!
> authenticateUser.action ... it uses
> org.infoglue.deliver.applications.actions.ExtranetLoginAction.class
> - if user credentials are good, user is redirected to returnAddress,
> if not invalidLogin is return and webwork redirects user to /deliver/
> extranetLoginError.vm
>
> I'd prefer to redirect user on my dynamic page instead of the infoglue
> velocity page.
>
> Is there a way to define othere url like logoutUrl, invalidLoginUrl,
> noAccess into repository settings ?
>
> Right now, I'm on my way to re-write ExtranetLoginAction to make it
> work the way i want to. I would have like to inherit from this class,
> but it is a final one, so I can't inherit ='(
>
> Any idea to make this easier ?
>
> __
> Romain
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july