Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Redirect in login component
rajivgupta
Hi All,
I was trying to build the a custom login component with the help of the sample given in the developer guide for livsite 2.2.1 .
the code is -------
public class CustomerLogin implements LoginIfc, AuthNavigationIfc
{
// workarea relative path to login file
public static final String PASSWORD_FILE =
"templatedata/Retail/Customer/users.xml";
// authentication xpath to user
public static final String XPATH_AUTH = "/users/user[username='%1' and
password='%2']";
// username parameter
public static final String PARAM_USERNAME = "username";
// password parameter
public static final String PARAM_PASSWORD = "password";
/**
* Control post-login navigation
*/
public String getNextPage(EndUserSite site,
EndUserIfc user, String lastPageVisited)
{
String target = site.getLoginPage();
if (user.getIsLoggedIn(site.getName()))
{
target = (target.equals(lastPageVisited))
? "Account Summary" : lastPageVisited;
}
return target;
}
/**
* Handle login.
*/
public int login(Map params, EndUserSite site, EndUserIfc user)
{
String username = (String) params.get(PARAM_USERNAME);
String password = (String) params.get(PARAM_PASSWORD);
if (null == username || null == password)
{
return LOGIN_ERROR;
}
try
{
String filePath = user.getFileDAL().getWebRoot(site)
+ user.getFileDAL().getSeparator()
+ PASSWORD_FILE;
DOMWrapper dom = new DOMWrapper(user.getFileDAL().read(filePath));
105
Sample Login Implementation
String xpath = StringUtil.replaceFirst(StringUtil.replaceFirst(
XPATH_AUTH, "%2", password), "%1", username);
Node userNode = dom.selectSingleNode(xpath);
// test for node, then double check username/password value
if (null == userNode
|| !username.equals(dom.getNodeValue(userNode, PARAM_USERNAME))
|| !password.equals(dom.getNodeValue(userNode, PARAM_PASSWORD)))
{
return LOGIN_ERROR;
}
// populate a customer profile
Profile profile = Profile.getProfile(user);
profile.setAnonymous(false);
profile.setUserName(username);
user.setLocale(new Locale(dom.getNodeValue(userNode, "locale")));
user.setIsLoggedIn(true, site.getName());
return LOGIN_SUCCESS;
}
catch (SAXParseException e)
{
throw new ExternalException("Login Failed", e);
}
}
}
-----------------------------------------------
I am able to login but after login it is not re directing to the correct path .
I tried changing the value of target and hard-coded it to some url but everytime it takes me to the login page,
Can anyone help
Find more posts tagged with
Comments
tec_iwov
can you verify the logs that there are no error occurring?