Esempio n. 1
0
 public function OnInit()
 {
     if ($this->IsPostback) {
         if (isset($_POST["user_LoginID"]) && isset($_POST["user_Password"])) {
             $admun = $_POST["user_LoginID"];
             $admpw = $_POST["user_Password"];
             $user = User::GetByCredentials($admun, $admpw);
             if ($user != null) {
                 if ($user->ForcePasswordChange) {
                     $_SESSION["ResetPasswordUserID"] = $user->ID;
                     System::Redirect("~/account/resetPassword.page");
                 } else {
                     $_SESSION["Authentication.UserName"] = $admun;
                     $_SESSION["Authentication.Password"] = $admpw;
                     if (isset($_SESSION["LoginRedirectURL"])) {
                         System::Redirect($_SESSION["LoginRedirectURL"]);
                     } else {
                         System::Redirect("~/");
                     }
                 }
                 return true;
             } else {
                 $script = new HTMLControl();
                 $script->TagName = "script";
                 $script->Attributes[] = new WebControlAttribute("type", "text/javascript");
                 $script->InnerHTML = "window.addEventListener(\"load\", function() { Notification.Show('The user name or password you entered is incorrect', 'Invalid Credentials', 'Error'); });";
                 // child control has to go into the Section (which is control at index 1 on the page)
                 $this->Controls[1]->Controls[] = $script;
             }
         }
     }
 }
Esempio n. 2
0
function IsAdministrator()
{
    if (!isset($_SESSION["Authentication.UserName"]) || !isset($_SESSION["Authentication.Password"])) {
        return false;
    }
    $username = $_SESSION["Authentication.UserName"];
    $password = $_SESSION["Authentication.Password"];
    $user = User::GetByCredentials($username, $password);
    if ($user == null) {
        return false;
    }
    $_SESSION["Authentication.UserID"] = $user->ID;
    return true;
}
Esempio n. 3
0
 /**
  * Retrieves the currently logged in user, or NULL if no user is currently logged in.
  * @return \PhoenixSNS\Objects\User|NULL The currently logged in user, or NULL if no user is currently logged in.
  */
 public static function GetCurrent()
 {
     if (isset($_SESSION["Authentication.UserName"]) && isset($_SESSION["Authentication.Password"])) {
         return User::GetByCredentials($_SESSION["Authentication.UserName"], $_SESSION["Authentication.Password"]);
     }
     return null;
 }
Esempio n. 4
0
 public static function GetCurrent()
 {
     $CurrentTenant = Tenant::GetCurrent();
     if ($CurrentTenant == null) {
         return null;
     }
     // prevent a NOTICE from cluttering the log
     if (!isset($_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"]) || !isset($_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"])) {
         return null;
     }
     return User::GetByCredentials($_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"], $_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"]);
 }