I have a problem with package accounts-ui

Hello,

This package meteor ( accounts-ui and accounts-password ) work in my project but i don’t know how use this package to prevent users to access in my admin part.

I explain : I want if the currentUser is not login that the link of my administration redirect to the page connexion.

So, the page connexion is : localhost:3000/admin

If the currentUser is login he can go on the localhost:3000/admin/dashboard… for example but if the currentUser is not login I want a redirection to localhost:3000/admin.

However, i don’t know do this. Can you help me ?

Best Regards,

You have to configure this in the router, by adding either the useraccounts:iron-routing or useraccounts-flowrouting packages. In the router configuration for your dashboard page, you then use AccountsTemplates.ensureSignedIn to make sure the dashboard is only accessible to logged in users. With FlowRouter, you do this in triggersEnter.

And, you have to setup a sign-in route with AccountsTemplates.configureRoute('signIn'). I’m not sure if it’s possible to have the login route on admin and the secured route on admin/dashboard, though, since in this case the admin route would have to be configured as a group route.