Extranet

Overview

This is old. Use Community instead.

 

You can use the extranet if you want to have pages on your page that is password protected. In order to get access to these pages the user is required to have an username and a password.

 


Extranet user

Below you can see all the available drops on the extranet user object


Name Description
extranet_user.username Username of logged in user
extranet_user.logged_in? Boolean. Check if the user is logged in or not
extranet_user.extranet_group_ids Returns the ids of the groups that the extranet user belongs to
extranet_user.login_path Get the login path
extranet_user.logout_path Get the logout path
extranet_user.prepend_locale Missing description
   

 

Snippets


Login form for extranet user should look something like this:

{{ request.alert }}
<form action="{{ extranet_user.login_path }}" method="post">
  <input type="text" name="username" placeholder="Username" />
  <input type="password" name="password" placeholder="Password" />
  <button>Log in</button>
</form>

The tag {{ request.alert }} will display an error message if the credentials is invalid. We can use site translations to set what message should be used. Add a key called extranet.invalid_login.

To log out we need a link like this:

<a href="{{ extranet_user.logout_path }}">Log out</a>

When logged in users can view protected pages if they're assigned to the correct extranet group that the protected page requires.

To redirect user when login use:

<input type="hidden" name="redirect_to" value="/page-url" />

A full example would look something like this:

{% if extranet_user.logged_in? %}
  <a href="{{ extranet_user.logout_path }}">Log out</a>
{% else %}
  {{ request.alert }}
  <form action="{{ extranet_user.login_path }}" method="post">
    <input type="text" name="username" placeholder="Username" />
    <input type="password" name="password" placeholder="Password" />
    <button>Log in</button>
  </form>
{% endif %}

Updated: 2020-11-24