Hello, I followed the examples in these two pages to create a very simple authentication mechanism.
The authentication works fine when I add
Context.Authorize();
to the Init() method of each ViewModel independently
However, when I only add it to the MasterPage ViewModel in order to require authentication over all my pages I instead get a very strange behavior, where I am getting a page loading while redirects are added to the url resulting in something like this:
going on for many lines, but you get the point.
Any ideas as to why that might be? I’ve never worked with Authentication before so any ideas are welcome!
I see, that does make sense. However, according to the documentation:
If you want the same permission check for all pages, you can place the Authorize method call to the master page viewmodel. If you override the Init method in page viewmodels, make sure to properly call await base.Init(context); so the check is applied.
What other steps should I take to state that the /login url does not need to be authenticated so to resolve this problem?
You have to avoid calling Authorize in the specific case. For instance, using an if (Context.Route.Name != "YourLoginPage") condition or placing the Authorize call into a virtual method which you override to be empty in the LoginViewModel