protected function getAuth()
 {
     $auth = AuthorizedUser::getInstance();
     if (is_null($auth)) {
         throw new Exception("Unauthorized", 2);
     }
     return $auth;
 }
Esempio n. 2
0
 private static function _ChangeEmail($hash)
 {
     unset($_SESSION['isSend']);
     global $smarty;
     $oldEmail = $_GET['old_email'];
     $newEmail = $_GET['new_email'];
     $_user = new User();
     $userInfo = $_user->SetSamplingScheme(User::ACTIVATION_SCHEME)->GetByEmail($oldEmail);
     if (empty($userInfo)) {
         throw new Exception(SEND_INCORRECT_MAIL);
     }
     $userPass = $userInfo[$_user->ToPrfxNm(User::PASS_FLD)];
     $mail = new Mail();
     if ($mail->compareUniqueSignature($hash, $newEmail, $userPass)) {
         AuthorizedUser::ChangeEmail($oldEmail, $newEmail, $userPass);
     } else {
         throw new Exception(ERROR_CHANGE_MAIL);
     }
     $smarty->assign('isGoAcc', true)->assign('successMsg', 'E-mail успешно изменен.');
 }
Esempio n. 3
0
<?php

@session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/scripts/lib/reg_auth.inc';
AuthorizedUser::Unauthorized();
Esempio n. 4
0
if (isset($_POST['submit'])) {
    $bool = isset($_SESSION['attempts']);
    $_SESSION['attempts'] = $bool ? $_SESSION['attempts'] + 1 : 1;
    $post = GetPOST();
    $login = $post['login'];
    $pass = $post['pass'];
    try {
        //captcha checking
        if (isset($_SESSION['attempts']) && $_SESSION['attempts'] >= NUMBER_OF_LOGIN_ATTEMPTS) {
            $key_string = isset($_POST['keystring']) ? $_POST['keystring'] : '';
            $bool = isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] === $key_string;
            if ($bool) {
                $_SESSION['attempts'] = NULL;
            } elseif ($_SESSION['attempts'] > NUMBER_OF_LOGIN_ATTEMPTS) {
                $smarty->assign('errorCaptcha', ERROR_CAPTCHA);
                throw new Exception('');
            }
        }
        try {
            (new DataHandling())->validatePassword($pass, ERROR_LOGIN);
            AuthorizedUser::Login($login, $pass);
            $_SESSION['attempts'] = null;
            Redirect('/profile');
        } catch (Exception $e) {
            $errorMsg = $e->getMessage();
        }
    } catch (Exception $e) {
    }
}
$smarty->assign('fromUri', $fromUri)->assign('login', isset($login) ? $login : '')->assign('captcha_img_url', sprintf('/kcaptcha/captcha.php?%s=%s', session_name(), session_id()))->assign('hasCaptcha', isset($_SESSION['attempts']) && $_SESSION['attempts'] >= NUMBER_OF_LOGIN_ATTEMPTS)->assign('errorMsg', isset($errorMsg) ? $errorMsg : null)->display('login.tpl');
unset($_SESSION['captcha_keystring']);
Esempio n. 5
0
 $post = GetPOST();
 if (isset($post['submit'])) {
     $data_h = new DataHandling();
     switch ($type) {
         case DELETE_ACC:
             if ($post['submit'] == 'delete') {
                 AuthorizedUser::DeleteAccount($_SESSION['email']);
                 Redirect();
             } elseif ($post['submit'] == 'cancel') {
                 Redirect('/profile');
             }
             break;
         case CHANGE_PASS:
             extract($post);
             $data_h->validatePassword($new_pass)->validateRepeatPasswords($new_pass, $re_new_pass);
             AuthorizedUser::ChangePassword($login, $pass, $new_pass);
             DisplaySuccess('isChangePass', true);
             break;
         case CHANGE_EXTRA_DATA:
             $_user->SetFieldByName(User::DESCRIPTION_FLD, $post['additional'])->UpdateByLogin($post['login']);
             DisplaySuccess('extra_data', true);
             break;
         case CHANGE_CONTACT:
             extract($post);
             if (!empty($phone)) {
                 $data_h->validatePhone($phone);
             }
             (new DataHandling())->ValidateRoom($room);
             $_user->SetFieldByName(User::ROOM_FLD, $room)->SetFieldByName(User::PHONE_FLD, $phone)->UpdateByLogin($login);
             DisplaySuccess('contact_data', true);
             break;