Skip to content
This repository was 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(forceAuth || allowedStates);

Name Type Description
forceAuth Boolean Set to true if you would like the user to only have access to approved states until they are authenticated. Otherwise, set it to false.
allowedStates Array of Strings A list of states that may be visited before authentication. Should include login and register states.
* The first parameter is either a boolean or array of strings.

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. NOTE: Make sure to add an (name).html file to the views/user/ directory.
resource String 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.
path String The url that the form will display when visible.
form String (Optional) The url to the login form.
override Object (Optional) An object that provides override templates and controllers for the states.

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

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