Route Protection

Route protection means protecting any defined path from unauthorized access. For example, Signin or Signup pages are common paths/unrestricted paths and any user can access it. However there are many paths or pages that only loggedin users can access, those paths are called Protected Routes. In Crema, we have provided the functionality of route protection, you have to follow the following steps to protect the route:-

Go to the file, where the routes have been declared. For example, let's go to the dashboard file where the dashboard related routes have been declared, the file can be found at:-

src/modules/dashboard/index.js

While declaring the route, you have to pass one extra property named "auth" in route object in order to make the route protected.

If this 'auth' property is added, this route will be protected and requires a loggedin user to access this path and if this property is not passed, then this path is directly accessible without any condition.

Last updated