# Portal customization

The portal is the visible part of LemonLDAP::NG, all user interactions are displayed on it.

## Skin

LemonLDAP::NG is shipped with 3 skins:

- pastel
- impact
- dark

But you can make your own, see Skin customization below.

### Default skin

You can change the default skin in Manager: `General Parameters` > `Portal` > `Customization` > `Default skin`.

### Skin rules

You might want to display different skin depending on the URL that was called before being redirected to the portal, or the IP address of the user.

To achieve this, you can create a rule in the Manager: select `General Parameters` > `Portal` > `Customization` > `Skin display rules` on click on “New key”. Then fill the two fields;

- Rule: a Perl expression (you can use %ENV hash to get environment variables, or $_url to get URL called before redirection, or $ipAddr to use user IP address). If the rule evaluation is true, the corresponding skin is applied.
- Skin: the name of the skin to use.

### Skin files

A skin is composed of different files:

- .tpl: Perl HTML::Template files, for HTML content
- .css: CSS (styles)
- .js: Javascript
- images and other media files

A skin will often refer to the `common` skin, which is not a real skin, but shared skin objects (like scripts, images and CSS).

### Skin customization

If you modify directly the skin files, your modifications will certainly be erased on the next upgrade.

To customize a skin, the simplest way is to create a new skin folder:

    cd portal/skins
    mkdir myskin
    mkdir myskin/css
    mkdir myskin/images

Then create symbolic links on template files, as you might not want to rewrite all HTML code (else, do as you want).

    cd myskin
    ln -s ../pastel/*.tpl .

We include some template files that can be customized:

- customhead.tpl : HTML header markups (like CSS, js inclusion)
- customheader.tpl : HTML code int the header div
- customfooter.tpm : HTML code in the footer div

To use custom files, delete links and copy them into your skin folder:

    rm custom*
    cp ../pastel/custom* .

Then you only have to write `myskin/css/styles.css` and add your media to `myskin/images`. Put all custom HTML code in the custom template files.

To configure your new skin in Manager, select the custom skin, and enter your skin name in the configuration field.

### Error messages

Error messages are defined in source code. If they really do not please you, override them! You just need to know the ID of the error (look at Portal/Simple.pm) and then add to `lemonldap-ng.ini`:

    [portal]

    # Custom error messages
    error_0 = Big brother is watching you, authenticated user

### Template parameters

Template parameters are defined in source code. If you need to add a template parameter for your customization, then add to `lemonldap-ng.ini`:

    [portal]

    # Custom template parameters
    tpl_myparam = world

Then you will be able to use it in your template like this:

    Hello <TMPL_VAR NAME="myparam">!

## Other parameters

- Auto complete: allow the browser to remember the password (for password based authentication backends)
- Check last logins: displays a checkbox on login form, allowing user to check his login history right after opening session
- User attribute: which session attribute will be used to display `Connected as` in the menu
- New window: open menu links in new window
- Anti iframe protection: will kill parent frames to avoid some well known attacks
- Password Management:
  - Reset password: display a link to reset a password (for password based authentication backends)
  - Require old password: used only in the password changing module of the menu, will check the old password before updating it
  - Hide old password: used only if the password need to be reset by the user (LDAP password policy), will hide the old password input
  - Send mail on password change: send a mail if the password is changed from the Menu, or from forced password reset (LDAP password policy)

If you enable auto completion, authentication level will be decreased (-1) as you do not ask the user to type its password (it could be in browser passwords wallet).