Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

FormioAuth Provider

Randall Knutson edited this page Jul 27, 2016 · 10 revisions

.setForceAuth(bool);

Name Type Description
allowed Boolean Set to true if you would like the user to only have access to the login page until they are authenticated. Otherwise, set it to false.

Example: FormioAuthProvider.setForceAuth(true);

.setStates(anonState, authState);

Name Type Description
anonState String The login state. Defaults to "login.auth".
authState String The state the user is redirected to after login. Defaults to "home".

Example: FormioAuthProvider.setStates('auth.login', 'home');

.register(name, resource, path);

Name Type Description
name String The name of your login template.
    <br /><br /> <i>NOTE: Make sure to add an (name).html file to the `views/user/` directory.</i></td>
</tr>
<tr>
    <td>resource</td>
    <td>String</td>
    <td>The resource that the login form is tied to. Set to null if you are tying the form to more than one resource. For example, if you had "employees" and "managers" logging in on the same form, you would set it to null. The form itself will confirm which resource the user is associated with.</td>
</tr>
<tr>
    <td>path</td>
    <td>String</td>
    <td>The url that the form will display when visible.</i></td>
</tr>

Example: FormioAuthProvider.register('login', 'user', 'login');

  • FormioAuthProvider - This allows you to register the authentication login pages and provide the authenticated and anonymous states.

.config(function(FormioAuthProvider) {

// Set the base url for formio.
FormioAuthProvider.setStates('auth.login', 'home');
FormioAuthProvider.setForceAuth(true);
FormioAuthProvider.register('userLogin', 'user', 'user/login');
FormioAuthProvider.register('customerLogin', 'customer', 'customer/login');
```
  • FormioAuth - You need to run the init() method in order to initialize all of the authentications.

.run(function(FormioAuth) {

// Initialize the Form.io authentication provider.
FormioAuth.init();
```
Clone this wiki locally