本文整理汇总了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;
}
示例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;
}
示例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');
}
}
示例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";
}
}
}
示例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('/');
}
}
}
示例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);
}
}
}
示例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>";
}
}
}
示例8: fetchMember
/**
* Fetch Member
*
* @return array
*/
public static function fetchMember()
{
if (!self::$member) {
self::$member = Authentication::GetAuthData();
}
return self::$member;
}
示例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())));
}
}
示例10: __construct
function __construct()
{
Authentication::require_admin();
$this->is_admin_page = true;
// updates?
$this->update_judge_status();
}
示例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
}
示例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;
}
示例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());
}
示例14: initialize
private function initialize()
{
$auth = Authentication::getInstance();
if (!$auth->isLogin() || !$auth->isRole(SystemUser::ROLE_ADMIN)) {
throw new Exception('Access denied');
}
}
示例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;
}