當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Authentication類代碼示例

本文整理匯總了PHP中Authentication的典型用法代碼示例。如果您正苦於以下問題:PHP Authentication類的具體用法?PHP Authentication怎麽用?PHP Authentication使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Authentication類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: login

 public function login()
 {
     if ($this->check_session()) {
         return true;
     }
     $restTransportInstance = new \RestTransport(\Config::get('yousendit.host'), \Config::get('yousendit.api_key'));
     \Session::set('ysi.sTr', $restTransportInstance);
     $authInstance = new \Authentication(\Config::get('yousendit.host'), \Config::get('yousendit.api_key'), \Session::get('ysi.sTr'));
     $auth = $authInstance->login(\Config::get('yousendit.email'), \Config::get('yousendit.password'));
     $errorStatus = $auth->getErrorStatus();
     $token = $auth->getAuthToken();
     if (!empty($errorStatus)) {
         $this->errorcode = $errorStatus->getMessage();
         $this->errormessage = $errorStatus->getCode();
         return false;
     } else {
         if (empty($token)) {
             $this->errormessage = 'Invalid apikey or hostname!';
             return false;
         } else {
             \Session::set('ysi.sEmail', \Config::get('yousendit.email'));
             \Session::set('ysi.sPass', \Config::get('yousendit.password'));
             \Session::set('ysi.sToken', $token);
             \Session::set('ysi.sApp', \Config::get('yousendit.api_key'));
             \Session::set('ysi.sHost', \Config::get('yousendit.host'));
             \Session::set('ysi.sUserAgent', 'we');
             return true;
         }
     }
     return false;
 }
開發者ID:EdgeCommerce,項目名稱:edgecommerce,代碼行數:31,代碼來源:base.php

示例2: fromXML

 public static function fromXML(SimpleXMLElement $xml = null)
 {
     $auth = null;
     if (!empty($xml)) {
         $auth = new Authentication();
         $auth->setType((string) $xml->type);
         if ($data = Data::fromXML($xml->data)) {
             $auth->setData($data);
         }
     }
     return $auth;
 }
開發者ID:kyroskoh,項目名稱:apigrove,代碼行數:12,代碼來源:Authentication.class.php

示例3: authenticate

 protected function authenticate()
 {
     $auth = new Authentication();
     if (($user = $auth->authenticate($_POST['Login']['Username'], hash('sha512', $_POST['Login']['Password']))) !== false) {
         if (!isset($_SESSION['Authenticated'])) {
             $_SESSION['Authentication'] = array();
         }
         $_SESSION['Authentication']['User'] = $user;
         $_SESSION['Authentication']['LoggedIn'] = true;
     } else {
         $GLOBALS['Smarty']->assign('errormessage', 'Login fehlgeschlagen');
     }
 }
開發者ID:OdysseyDE,項目名稱:omer_team_registration,代碼行數:13,代碼來源:AuthenticatedCommand.php

示例4: StoreAuth

 function StoreAuth($table)
 {
     $auth = new Authentication();
     $this->message = "NOT Authenticated";
     if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
         $email = $_REQUEST['username'];
         $password = $_REQUEST['password'];
         if ($auth->credentials($email, $password, $table)) {
             $this->message = "Authenticated";
             StoreSession::loginPage('indexauth.php', $email);
         } else {
             $this->message = "NOT Authenticated";
         }
     }
 }
開發者ID:nateirwin,項目名稱:custom-historic,代碼行數:15,代碼來源:StoreAuth.php

示例5: callback

 /**
  *
  *
  * @return void
  */
 public function callback()
 {
     $config = Config::get('opauth');
     $Opauth = new Opauth($config, FALSE);
     if (!session_id()) {
         session_start();
     }
     $response = isset($_SESSION['opauth']) ? $_SESSION['opauth'] : array();
     $err_msg = null;
     unset($_SESSION['opauth']);
     if (array_key_exists('error', $response)) {
         $err_msg = 'Authentication error:Opauth returns error auth response.';
     } else {
         if (empty($response['auth']) || empty($response['timestamp']) || empty($response['signature']) || empty($response['auth']['provider']) || empty($response['auth']['uid'])) {
             $err_msg = 'Invalid auth response: Missing key auth response components.';
         } elseif (!$Opauth->validate(sha1(print_r($response['auth'], true)), $response['timestamp'], $response['signature'], $reason)) {
             $err_msg = 'Invalid auth response: ' . $reason;
         }
     }
     if ($err_msg) {
         return Redirect::to('account/login')->with('error', $err_msg);
     } else {
         $email = $response['auth']['info']['email'];
         $authentication = new Authentication();
         $authentication->provider = $response['auth']['provider'];
         $authentication->provider_uid = $response['auth']['uid'];
         $authentication_exist = Authentication::where('provider', $authentication->provider)->where('provider_uid', '=', $authentication->provider_uid)->first();
         if (!$authentication_exist) {
             if (Sentry::check()) {
                 $user = Sentry::getUser();
                 $authentication->user_id = $user->id;
             } else {
                 try {
                     $user = Sentry::getUserProvider()->findByLogin($email);
                 } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
                     $user = Sentry::register(array('first_name' => $response['auth']['info']['first_name'], 'last_name' => $response['auth']['info']['last_name'], 'email' => $email, 'password' => Str::random(14)), TRUE);
                 }
                 $authentication->user_id = $user->id;
             }
             $authentication->save();
         } else {
             $user = Sentry::getUserProvider()->findById($authentication_exist->user_id);
             Sentry::login($user);
             Session::put('user_image', $response['auth']['info']['image']);
             return Redirect::to('/');
         }
     }
 }
開發者ID:nozkok,項目名稱:laravel-4-starter,代碼行數:53,代碼來源:SocialController.php

示例6: _run

 protected function _run($request)
 {
     if ($this->requestMethod == 'POST' && count($request) == 0) {
         // User tries to login
         Authentication::login($_POST['username'], $_POST['password']);
         if (!Authentication::authenticated()) {
             Headers::sendStatusUnauthorized();
             return;
         } else {
             Headers::sendStatusOk();
             echo "login succeeded<br>";
             return;
         }
     } else {
         Authentication::authenticate();
         if (!Authentication::authenticated()) {
             Headers::sendStatusUnauthorized();
             return;
         }
         if ($this->requestMethod == 'GET' && count($request) > 0) {
             // User info requested
             echo "requesting userinfo of user " . $request[0];
         } else {
             // Bad request
             Headers::sendStatusMethodNotAllowed();
             echo "Method not allowed<br>";
             print_r($request);
         }
     }
 }
開發者ID:tuksik,項目名稱:zarafa-rest-api,代碼行數:30,代碼來源:class.UsersResourceController.php

示例7: processLogin

 public static function processLogin()
 {
     if (isset($_REQUEST['submit'])) {
         //check for submission
         $user = new User();
         $username = $_REQUEST['username'];
         $password = $_REQUEST['password'];
         $loaded = $user->load_by_username($username);
         if ($loaded) {
             if ($user->verify_password($password)) {
                 if ($user->isActivated === '1') {
                     Authentication::setAuthentication(True);
                     self::performLoginActions($user->username);
                 } else {
                     echo "<span style='color:red;'>Your Account has not yet been activated, please contact your system administrator</span>";
                 }
             } else {
                 //password may not have been hashed yet
                 $user->passwordHash = User::encodePassword($user->passwordHash);
                 if ($user->verify_password($password)) {
                     $user->save();
                     Authentication::setAuthentication(TRUE);
                     self::performLoginActions($user->username);
                 } else {
                     //if here, password is wrong
                     echo "<h4 style='color:red;'>Invalid password</h4>";
                 }
             }
             //continue processing
         } else {
             //handling for wrong username, allow registration
             echo "<h4 style='color:red;'>Invalid username</h4>";
         }
     }
 }
開發者ID:brd69125,項目名稱:Smart_Home,代碼行數:35,代碼來源:authentication.class.php

示例8: fetchMember

 /**
  *	Fetch Member
  *
  *	@return	array
  */
 public static function fetchMember()
 {
     if (!self::$member) {
         self::$member = Authentication::GetAuthData();
     }
     return self::$member;
 }
開發者ID:ADMTec,項目名稱:effectweb-project,代碼行數:12,代碼來源:acp_registry.php

示例9: login

 public function login()
 {
     try {
         $this->User->validate = $this->User->validate_login;
         $_POST = Utils::sanitazeArray($_POST);
         $this->User->data = $_POST[$this->User->name];
         if ($this->User->validates()) {
             $this->User->data['senha'] = Authentication::password($this->User->data['senha']);
             /**
              * toda a minha validação de status da conta, usuario ou empresa está na procedure.
              * referencia MODEL/USUARIOS.PHP
              * metodo LOGAR
              */
             $usuario[$this->User->name] = $this->User->logar($this->User->data['email'], $this->User->data['senha']);
             if (count($usuario[$this->User->name]) > 0 && $usuario[$this->User->name]['status'] == true) {
                 echo json_encode(array('erro' => false, 'usuario' => array_shift($usuario)));
             } else {
                 throw new Exception('Não foi possivel logar, verifique usuário e senha, ou verifique seu e-mail para ativar sua conta!');
             }
         } else {
             echo json_encode(array('erro' => true, 'erros' => $this->User->validateErros));
         }
     } catch (Exception $ex) {
         echo json_encode(array('erro' => true, 'mensagem' => utf8_decode($ex->getMessage())));
     }
 }
開發者ID:brunoblauzius,項目名稱:sistema,代碼行數:26,代碼來源:WebservicesController.php

示例10: __construct

 function __construct()
 {
     Authentication::require_admin();
     $this->is_admin_page = true;
     // updates?
     $this->update_judge_status();
 }
開發者ID:jlsa,項目名稱:justitia,代碼行數:7,代碼來源:admin_judge_daemons.php

示例11: login

 /**
  * Log user in
  */
 function login()
 {
     $params = $this->request->get('params', false);
     if ($params) {
         $rsa = new Crypt_RSA();
         $my_pub_key = ConfigOptions::getValue('frosso_auth_my_pub_key');
         $my_pri_key = ConfigOptions::getValue('frosso_auth_my_pri_key');
         $rsa->loadKey($my_pri_key);
         $decrypted_params = $rsa->decrypt($params);
         if ($decrypted_params) {
             list($email, $token, $timestamp) = explode(';', $decrypted_params);
             if ($email && $token && $timestamp) {
                 if ($token == ConfigOptions::getValue('frosso_auth_my_pri_token') && time() - 60 * 10 < $timestamp && $timestamp < time() + 60 * 10) {
                     Authentication::useProvider('FrossoProvider', false);
                     Authentication::getProvider()->initialize(array('sid_prefix' => AngieApplication::getName(), 'secret_key' => AngieApplication::getAdapter()->getUniqueKey()));
                     Authentication::getProvider()->authenticate($email);
                 } else {
                     $this->response->forbidden();
                 }
                 // token non valido
             } else {
                 $this->response->badRequest(array('message' => 'Parametri non '));
             }
             // parametri non validi
         } else {
             $this->response->badRequest(array('message' => 'Parametri non validi'));
         }
     } else {
         $this->response->badRequest(array('message' => 'Parametri non settati'));
     }
     // parametri non settati
 }
開發者ID:NaszvadiG,項目名稱:ACModules,代碼行數:35,代碼來源:FrossoAuthController.class.php

示例12: filterFields

 /**
  * filters field values like checkbox conversion and date conversion
  *
  * @param array unfiltered values
  * @return array filtered values
  * @see DbConnector::filterFields
  */
 public function filterFields($fields)
 {
     $authentication = Authentication::getInstance();
     $userId = $authentication->getUserId();
     $fields['usr_id'] = $userId['id'];
     return $fields;
 }
開發者ID:rverbrugge,項目名稱:dif,代碼行數:14,代碼來源:NewsTreeRef.php

示例13: cadastro

 public function cadastro($created)
 {
     /**
      * criar uma pessoa
      */
     $modelPessoa = new Pessoa();
     $pessoasId = $modelPessoa->genericInsert(array('tipo_pessoa' => 1, 'created' => $created));
     /**
      * criar uma pessoa fisica
      */
     $ModelPF = new Fisica();
     $ModelPF->genericInsert(array('pessoas_id' => $pessoasId, 'cpf' => '00000000000', 'nome' => $this->getNome()));
     /**
      * criar um contato
      */
     $modelContato = new Contato();
     $contatoId = $modelContato->genericInsert(array('telefone' => Utils::returnNumeric($this->getPhone()), 'tipo' => 1));
     $modelContato->inserirContato($pessoasId, $contatoId);
     /**
      * criar um email
      */
     $modelEmail = new Email();
     $modelEmail->inserirEmailPessoa($pessoasId, $this->getEmail());
     /**
      * criar um usuario
      */
     $modelUsuario = new Usuario();
     $usuarioId = $modelUsuario->genericInsert(array('roles_id' => 1, 'pessoas_id' => $pessoasId, 'status' => 1, 'perfil_teste' => 0, 'created' => $created, 'email' => $this->getEmail(), 'login' => $this->getEmail(), 'senha' => Authentication::password($this->getPhone()), 'chave' => Authentication::uuid(), 'facebook_id' => $this->getFacebookId()));
     $modelCliente = new Cliente();
     $modelCliente->genericInsert(array('pessoas_id' => $pessoasId, 'status' => 1, 'sexo' => 0));
     return $modelCliente->recuperaCliente($this->getNome(), $this->getPhone());
 }
開發者ID:brunoblauzius,項目名稱:sistema,代碼行數:32,代碼來源:Facebook.php

示例14: initialize

 private function initialize()
 {
     $auth = Authentication::getInstance();
     if (!$auth->isLogin() || !$auth->isRole(SystemUser::ROLE_ADMIN)) {
         throw new Exception('Access denied');
     }
 }
開發者ID:rverbrugge,項目名稱:dif,代碼行數:7,代碼來源:InstallPlugin.php

示例15: saveToDb

 private function saveToDb($params)
 {
     $objAuth = Authentication::getInstance();
     $user_id = $objAuth->user_id;
     $objForm = new FormModel();
     $saveData = array();
     $saveData['form_id'] = $params['formSubmit']['id'];
     $saveData['user_id'] = $user_id;
     $saveData['fromPage'] = !empty($params['returnUrlRequest']) ? $params['returnUrlRequest'] : false;
     if (!empty($params['formSubmit']['fields'])) {
         foreach ($params['formSubmit']['fields'] as $fieldId => $value) {
             $fieldInfo = array();
             $fieldInfo['field_id'] = intval($fieldId);
             $fieldInfo['value'] = $value;
             $saveData['fields'][] = $fieldInfo;
         }
     }
     if (!empty($params['formSubmit']['userfields'])) {
         foreach ($params['formSubmit']['userfields'] as $fieldId => $value) {
             $fieldInfo = array();
             $fieldInfo['field_id'] = intval($fieldId);
             $fieldInfo['value'] = $value;
             $saveData['fields'][] = $fieldInfo;
         }
     }
     $submission_id = $objForm->saveSubmission($saveData);
     return $submission_id;
 }
開發者ID:ngardner,項目名稱:BentoCMS,代碼行數:28,代碼來源:Form.php


注:本文中的Authentication類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。