예제 #1
0
파일: SsoTrait.php 프로젝트: phwoolcon/auth
 protected function getSsoUserData($input)
 {
     try {
         $site = SsoSite::getSiteDataByReturnUrl(fnGet($input, 'notifyUrl'));
         $initToken = fnGet($input, 'initToken');
         $initTime = fnGet($input, 'initTime');
         if (!$this->checkInitToken($initTime, $initToken, $site)) {
             return ['error' => __('Invalid SSO init token')];
         }
         if (!($user = Auth::getUser())) {
             return ['error' => false, 'user_data' => ['uid' => null]];
         }
         $ssoData = ['error' => false, 'user_data' => ['uid' => $user->getId(), 'username' => $user->getUsername(), 'email' => $user->getEmail(), 'avatar' => $user->getAvatar()], 'user' => $user, 'site' => $site];
         return $ssoData;
     } catch (Exception $e) {
         Log::exception($e);
         return ['error' => __('Other error %code% - %time%', ['code' => $e->getCode(), 'time' => date(DateTime::MYSQL_DATETIME)])];
     }
 }
예제 #2
0
파일: di.php 프로젝트: phwoolcon/auth
<?php

use Phwoolcon\Auth\Auth;
Auth::register($di);