Issue
When authentication is enabled, all users visiting any controller webpages in cakephp will be directed to a login page. However, for pages under webroot folder, users will not be re-directed to log in. How can one force users visiting pages under webroot to log in to cakephp? The pages under webroot were written in angularjs.
This question is similar to the question asked below.
Redirect all webpages under webroot to login page in Cakephp
However, I am re-asking the question because;
- I am using cakephp ver3.x which is different
- The answer provided in that question does not work
Solution
those pages use angularjs. So, the correct way is to get those angularjs pages to redirect user to the login page? Is this correct?
The correct way for a single page app would be to authenticate the user against an API and then use a stateless auth, which is commonly a JWT token for an angular app. Your angular user service should tell you the state if the user is logged in or not. You can then either redirect him or log him in via API call.
See http://florian-kraemer.net/2014/07/cakephp-and-token-based-auth-with-angular-js/
Answered By - floriank
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.