Overview
If your application requires a user to be logged in to access a route, you may define login credentials in your emtrey.config.js
file. These credentials will be used in conjunction with the provided login URL, and automatically entered before visiting each route.
Example
The following example shows an emtrey.config.js
configured to provide user credentials to a login page.
module.exports = { login: { url: 'login', user: 'YOUR_USERNAME', password: 'YOUR_PASSWORD' }, routes: { '*': { auth: true, } } }
Let’s break the properties of login
down line-by-line.
- The
url
property defines which route Emtrey will visit in order to access the login form.- Defaults to
login
. If the authentication URL is not/login
, you can use theurl
property to override it. - Note: Do NOT add a leading slash. (e.g.
'/sign-in'
)
- Defaults to
- The
user
property should be set to a valid email or username for your application. - The
password
property is the passphrase for theuser
property.
With these properties set, Emtrey will try to autofill fields on your login form automatically.
auth: true
to the route.
In the above example, the *
tells Emtrey to apply the configuration to all discovered routes. Every time Emtrey processes a route, it will always ensure the user (defined in login
) is authenticated.
Having Trouble with Authentication?
Some application may have an non-standard approach to authentication, and Emtrey may not be able to automatically populate the fields or submit button. If you are experiencing issues with authentication, reach out to support at hello@emtrey.io.