Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6869313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:32:34+00:00 2026-05-27T03:32:34+00:00

I’ve had a look at the other questions relating to this topic but none

  • 0

I’ve had a look at the other questions relating to this topic but none have been useful.

Expected Outcome

From a homepage with links to different web apps, the user clicks to access a web app. The user is redirected to the login page. I’ve tried to override the login function to auto-login network users based on a lookup on their IP address. Their machine name is stored as their username in the database and all the passwords are the same. This is validated and the user is automatically logged in and redirected to the web apps home page, with no need to see a login form.

Note: this auto-login works when accessing the web address directly, but this problem started when I added in the “dashboard” of web apps. However, this is required so there is only one shortcut on the users desktop.

routes.php Code

Router::connect('/', array('controller' => 'cns', 'action' => 'view'));

app_controller.php Code

function beforeFilter() {

 $this->Auth->allow('display');

 # Users need authorised before viewing these pages
 $this->Auth->deny('index','view', 'add','edit','delete'); 

 $this->Auth->loginRedirect = array( 'controller'=>'cns', 'action'=>'view');
 $this->Auth->logoutRedirect = array( 'controller'=>'pages', 'action'=>'logged_out');

}       

users_controller.php Code

function beforeFilter() {
 $this->Auth->autoRedirect = false;
}

function login () {

 # Automatic login based on computer name
 $this->data['User']['password'] = $this->Auth->password('qwerty');

 # Result: x-xxxxxx.domain.local (function declared below)
 $full_host = gethostbyaddr($this->get_user_IP_address());

 # Result: x-xxxxxx[.domain.local]
 $position_of_split = strrpos($full_host, ".gmi.local");

 # Result: x-xxxxxx
 $computer_name = substr($full_host,0,$position_of_split);

 # If username is not been provided, use the computer name discovered by auto-login
 (!isset($this->data['User']['username']) ? $this->data['User']['username'] = $computer_name : null);

 # If login is successful, redirect to view. Otherwise, echo error message.
 if($this->Auth->login($this->data)){
  $this->redirect(array('controller' => 'cns', 'action' => 'view'));
 } else {
  echo "Unable to log you in. Please advise IT."; die;
 }
}

function get_user_IP_address() {
 if (isset($_SERVER)) {
  if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
   return $_SERVER["HTTP_X_FORWARDED_FOR"];         
   if (isset($_SERVER["HTTP_CLIENT_IP"]))
    return $_SERVER["HTTP_CLIENT_IP"];
   return $_SERVER["REMOTE_ADDR"];
 }

 if (getenv('HTTP_X_FORWARDED_FOR'))
  return getenv('HTTP_X_FORWARDED_FOR');

 if (getenv('HTTP_CLIENT_IP'))
  return getenv('HTTP_CLIENT_IP');

 return getenv('REMOTE_ADDR');
}

If you need further code or explanation, just ask in the comments.

Thanks in advance. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:32:35+00:00Added an answer on May 27, 2026 at 3:32 am

    I don’t know if you found the solution to your problem but I had the same problem and found the following article which describes the cause and provides workaround.

    Infinite loop login redirect

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.