User Login

One of the most important functions of a community site is that it should identify the requesting user. VCE comes with built-in functionality that allows a developer to implement user login in a very short time.

The Struts configuration for the login action may look as follows:

<form-bean name="signinForm" type="com.ndc.usercontent.struts.actions.forms.SigninForm" />

<action path="/auth/login"
  name="signinForm"
  scope="request"
  validate="true"
  input="/index.jsp"
  type="com.escenic.profile.presentation.struts.LoginAction">
  <forward name="success" path="/auth/community/login.do"/>
  <forward name="error" path="/"/>
</action>

<action
  path="/auth/community/login"
  scope="request"
  name="signinForm"
  validate="true"
  input="/index.jsp"
  parameter="userProfile"
  type="com.ndc.usercontent.struts.actions.login.Login">
  <forward name="error" path="/" />
</action>

Since VCE works as a plug-in on top of ECE, we need to delegate control from the first login action to the second one. The first action, /Login, makes the user log into ECE and the second action /auth/community/login makes the user log into VCE.

To add SSO support to your login component, please have a look at: SSO Support

The JSP template that renders the form to the user may look as follows:

<html:form action="/auth/login">
  <div>
    <label for="userName">User name:</label>
    <html:text tabindex="1" property="userName" size="10"/>
    <label for="userPassword">Password:</label>
    <html:password tabindex="2" property="password" size="10"/>
    <br/>
    <html:checkbox property="savePassword">Remember me</html:checkbox>
    <br/>
    <html:submit value="Login" tabindex="3" />
    <html:hidden property="targetUrl" value="/profile/"/>
    <html:hidden property="errorUrl" value="/profile/"/>
  <div>
</html:form>
Form PropertyDescription

userName

The user name of the requesting user

password

The password that identifies the requesting user

savePassword

Indicates if the login action should remember the user or not. If selected, the user will remain authenticated for a certain period of time.

targetUrl

The URL (absolute or relative to the publication) where the requesting user should be directed to after a successful login. If not specified, the action tries to find the configured forward named target. Note that, in our example configuration, we have not configured any such forward. In which case, the user is redirected to his or her profile section.

errorUrl

The URL (absolute or relative to the publication) where the requesting user should be directed to if the login attempt fails. On failure, the login action binds the relevant error messages to the request scope so that the template developer can display information relevant to the failed login attempt.

userName: contains error information related to the user name. Usually, the error property is present with the action error key "no_userName" to indicate that the user has not entered any user name. The error can be displayed using: <html:errors property="userName"/>,

password: contains error information related to the password field. Usually, the error property is present with action error key "no_password" to indicate that the user has not entered any password. The error can be displayed using: <html:errors property="password"/>

login_failed: indicates that the login attempt failed due to unknown user name or invalid password. The error can be displayed using: <html:errors property="login_failed"/>

login_failed_account_expired: indicates that the login attempt failed because the user's account expired. The error can be displayed using: <html:errors property="login_failed_account_expired"/>

login_failed_other: indicates that the login attempt failed because the user's credentials expired. The error can be displayed using: <html:errors property="login_failed_other"/>