Skip to content

Instantly share code, notes, and snippets.

@mlbiam
Created January 4, 2020 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlbiam/e857f27d0a7f999c04c1a0e8ca3ae462 to your computer and use it in GitHub Desktop.
Save mlbiam/e857f27d0a7f999c04c1a0e8ca3ae462 to your computer and use it in GitHub Desktop.
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
require_once('modules/Users/authentication/SugarAuthenticate/SugarAuthenticate.php');
class HeaderAuthenticate extends SugarAuthenticate
{
public $userAuthenticateClass = 'HeaderAuthenticateUser';
public $authenticationDir = 'HeaderAuthenticate';
public function __construct()
{
parent::__construct();
}
public function pre_login()
{
parent::pre_login();
$userid = $_SERVER['HTTP_USERID'];
$GLOBALS['log']->fatal("IN PRELOGIN - user - '" . $userid . "'");
if (isset($userid)) {
$GLOBALS['log']->fatal("IN PRELOGIN - authenticating - '" . $userid . "'");
global $mod_strings;
unset($_SESSION['login_error']);
$usr= new user();
$usr_id=$usr->retrieve_user_id($userid);
$GLOBALS['log']->fatal("IN PRELOGIN - user_id - '" . $usr_id . "'");
$usr->retrieve($usr_id);
$_SESSION['login_error']='';
$_SESSION['waiting_error']='';
$_SESSION['hasExpiredPassword']='0';
if ($usr->getPreference('loginfailed') != '' && $usr->getPreference('loginfailed') != 0) {
$usr->setPreference('loginfailed', '0');
$usr->savePreferencesToDB();
}
$GLOBALS['log']->fatal("IN PRELOGIN - done authenticating - '" . $userid . "'");
if (!empty($usr_id)) {
$_SESSION['authenticated_user_id'] = $usr_id;
}
if (!empty($_SESSION['authenticated_user_id']) || !empty($user_id)) {
$GLOBALS['current_user'] = new User();
if ($GLOBALS['current_user']->retrieve($_SESSION['authenticated_user_id'])) {
SugarApplication::redirect('/');
return true;
}
}
return false;
}
}
public function logout()
{
SugarApplication::redirect('/logout');
}
}
?>
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
require_once('modules/Users/authentication/SugarAuthenticate/SugarAuthenticateUser.php');
class HeaderAuthenticateUser extends SugarAuthenticateUser
{
public function authenticateUser($name, $password, $fallback=false, $checkPasswordMD5 = false)
{
$GLOBALS['log']->fatal("IN AUTHENTICATE USER");
$userid = $_SERVER['HTTP_USERID'];
$GLOBALS['log']->fatal("IN AUTHENTICATE USER - user - '" . $userid . "'");
}
public function loadUserOnLogin($name, $password, $fallback = false, $PARAMS = array())
{
$GLOBALS['log']->fatal("IN LOAD USER ON LOGIN");
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment