예제 #1
0
파일: Fwd.php 프로젝트: minutephp/auth
 public function index(string $jwt, string $url = '')
 {
     if ($payload = $this->jwtEx->decode($jwt)) {
         if ($user_id = $payload->user_id ?? 0) {
             if ($user = User::find($user_id)) {
                 if (!empty($payload->authorize)) {
                     /** @var User $user */
                     if ($user->verified == 'n') {
                         $user->ip_addr = $this->sniffer->getUserIP();
                         $user->verified = 'y';
                         $user->save();
                     }
                     $this->session->startSession($user_id);
                 }
                 if (!empty($payload->eventName)) {
                     $event = new UserEvent($user_id, $user->toArray());
                     $event->setData($payload->eventData ?? '');
                     $this->dispatcher->fire($payload->eventName, $event);
                 }
             }
         }
     } else {
         $params = ['msg' => 'Sorry this link has expired'];
     }
     return new Redirection($url ?: '/', $params ?? []);
 }
예제 #2
0
 /**
  * Session constructor.
  *
  * @param JwtEx $jwt
  * @param HttpRequestEx $request
  * @param HttpResponseEx $response
  * @param AccessManager $accessManager
  * @param UserInfo $userInfo
  * @param Config $config
  */
 public function __construct(JwtEx $jwt, HttpRequestEx $request, HttpResponseEx $response, AccessManager $accessManager, UserInfo $userInfo, Config $config)
 {
     $this->accessManager = $accessManager;
     $this->config = $config;
     $this->jwt = $jwt;
     $this->request = $request;
     $this->response = $response;
     $this->userInfo = $userInfo;
     $this->data = new stdClass();
     if ($cookie = $this->request->getCookie(self::COOKIE_NAME)) {
         if ($decoded = $this->jwt->decode($cookie)) {
             $this->data = $decoded;
         }
     }
 }