PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 17, 2022

[FIXED] Force users visiting pages under webroot to log in to cakephp

 January 17, 2022     angularjs, cakephp, cakephp-3.0, login, php     No comments   

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;

  1. I am using cakephp ver3.x which is different
  2. 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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing