Beispiel #1
0
 /**
  * Loginza TokenUrl
  */
 public function executeAuth(sfWebRequest $request)
 {
     $this->forward404Unless($token = $request->getParameter('token'));
     $loginza = new LoginzaAPI();
     $response = $loginza->getAuthInfo($token);
     $this->forward404Unless(isset($response->identity));
     $identity = IdentityTable::getInstance()->findOneByIdentity($response->identity);
     if ($identity) {
         $this->getUser()->signin($identity->getUser(), true);
         return $this->redirect('homepage');
     } else {
         $this->getUser()->setAttribute('loginza.identity', array('identity' => $response->identity, 'provider' => $response->provider, 'email_address' => isset($response->email) ? $response->email : '', 'username' => isset($response->nickname) ? $response->nickname : '', 'first_name' => isset($response->name->first_name) ? $response->name->first_name : '', 'last_name' => isset($response->name->last_name) ? $response->name->last_name : ''), 'loginza');
         return $this->redirect('loginza_signup');
     }
 }
 public function do_answer_from_server()
 {
     global $forum_user, $lang_common, $lang_fancy_login_loginza, $forum_config;
     if (!empty($_POST['token'])) {
         $widget_id = intval($forum_config['o_fancy_login_loginza_widget_id'], 10);
         $secret_key = forum_trim($forum_config['o_fancy_login_loginza_secret_key']);
         // Получаем профиль авторизованного пользователя
         $LoginzaAPI = new LoginzaAPI();
         $UserProfile = $LoginzaAPI->getAuthInfo($_POST['token'], $widget_id, md5($_POST['token'] . $secret_key));
         $prev_url = isset($_GET['return_url']) ? forum_trim($_GET['return_url']) : '';
         // проверка на ошибки
         if (is_object($UserProfile) && !empty($UserProfile->error_type)) {
             message(sprintf($lang_fancy_login_loginza['Error server'], forum_htmlencode($UserProfile->error_message)));
         } else {
             if (!empty($UserProfile) && $this->check_profile($UserProfile)) {
                 $this->process($UserProfile, $prev_url);
             }
         }
     }
     // Show ERROR
     message($lang_fancy_login_loginza['Error loginza']);
 }
Beispiel #3
0
<?php

/**
 * Пример кода использования авторизации через Loginza API
 */
header('Content-type: text/html; charset=utf-8');
session_start();
require_once 'libs/LoginzaAPI.class.php';
require_once 'libs/LoginzaUserProfile.class.php';
// объект работы с Loginza API
$LoginzaAPI = new LoginzaAPI();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Пример авторизации через Loginza API</title>

<!-- Insert Loginza Widget JavaScript Code -->
<script src="http://loginza.ru/js/widget.js" type="text/javascript"></script>

</head>
<body>
<?php 
// проверка переданного токена
if (!empty($_POST['token'])) {
    // получаем профиль авторизованного пользователя
    $UserProfile = $LoginzaAPI->getAuthInfo($_POST['token']);
    // проверка на ошибки
    if (!empty($UserProfile->error_type)) {
        // есть ошибки, выводим их