• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Authentication类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Authentication的典型用法代码示例。如果您正苦于以下问题:PHP Authentication类的具体用法?PHP Authentication怎么用?PHP Authentication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Authentication类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: install

 public static function install($data, &$fail, &$errno, &$error)
 {
     if (!$fail) {
         $auth = new Authentication();
         $salt = $auth->generateSalt();
         $passwordHash = $auth->hashPassword($data['DB']['db_passwd_insert'], $salt);
         $sql = "INSERT INTO `User` (`U_id`, `U_username`, `U_email`, `U_lastName`, `U_firstName`, `U_title`, `U_password`, `U_flag`, `U_salt`, `U_failed_logins`, `U_externalId`, `U_studentNumber`, `U_isSuperAdmin`, `U_comment`) VALUES (NULL, '{$data['DB']['db_user_insert']}', '{$data['DB']['db_email_insert']}', '{$data['DB']['db_last_name_insert']}', '{$data['DB']['db_first_name_insert']}', NULL, '{$passwordHash}', 1, '{$salt}', 0, NULL, NULL, 1, NULL);";
         $result = DBRequest::request($sql, false, $data);
         if ($result["errno"] !== 0) {
             $fail = true;
             $errno = $result["errno"];
             $error = isset($result["error"]) ? $result["error"] : '';
         }
     }
     return null;
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:16,代码来源:BenutzerErstellen.php


示例17: registerObjects

 public function registerObjects()
 {
     $key = 'class';
     if (!$this->parameterExists($key)) {
         throw new Exception("Parameter '{$key}' not set\n");
     }
     $classname = $this->getParameter($key);
     // user must log in
     $auth = Authentication::getInstance();
     $key = 'username';
     if (!$this->parameterExists($key)) {
         throw new Exception("Parameter '{$key}' not set\n");
     }
     $username = $this->getParameter($key);
     $key = 'password';
     if (!$this->parameterExists($key)) {
         throw new Exception("Parameter '{$key}' not set\n");
     }
     $password = $this->getParameter($key);
     $auth->login($username, $password, false);
     // user must have backend rights
     if ($auth->isLogin() && !$auth->isRole(SystemUser::ROLE_BACKEND)) {
         throw new Exception('Access denied.');
     }
     try {
         $this->director->pluginManager->loadPlugin($classname);
     } catch (Exception $e) {
         // normal plugin failed, try to load admin plugin
         $this->director->adminManager->loadPlugin($classname);
         //throw new Exception($e->getMessage());
     }
 }
开发者ID:rverbrugge,项目名称:dif,代码行数:32,代码来源:CliServer.php


示例18: __construct

 function __construct()
 {
     // find active entity
     parent::__construct();
     Authentication::require_admin();
     $this->is_admin_page = true;
 }
开发者ID:jlsa,项目名称:justitia,代码行数:7,代码来源:admin_submissions.php


示例19: write_rejudge_all

 function write_rejudge_all()
 {
     if (Authentication::is_admin() and $this->entity->submitable()) {
         $this->write_block_begin('Rejudge submissions');
         $this->write_form_begin($this->nav_script(null) . $this->entity->path() . "?rejudge_all=1", 'post');
         $this->write_form_end('Rejudge all submissions for this entity');
         $this->write_block_end();
     }
 }
开发者ID:jlsa,项目名称:justitia,代码行数:9,代码来源:PageWithEntity.php


示例20: setInformations

 private function setInformations()
 {
     try {
         $model = new UserModel();
         self::$informations = $model->getUser(Authentication::getInstance()->getUserId());
     } catch (InputNotSetException $e) {
         $e->getMessage();
     }
 }
开发者ID:kazuohirai,项目名称:awayfromswag,代码行数:9,代码来源:UserInformations.php



注:本文中的Authentication类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP AuthenticationController类代码示例发布时间:2022-05-23
下一篇:
PHP Authenticate类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap