示例#1
0
 public function vTicket()
 {
     $ticket = VkAuthTicket::model()->find(['scopes' => ['active', 'valid'], 'condition' => 't.ticket=:ticket AND t.ip=:ip', 'params' => [':ticket' => $this->auth_ticket, ':ip' => $this->ip]]);
     if ($ticket instanceof VkAuthTicket) {
         $this->ticket_id = $ticket->id;
     } else {
         $this->ticket_id = null;
         $this->addError('auth_ticket', 'Ticket does not exist or is not valid.');
     }
 }
示例#2
0
 /**
  * creates a token (with ticket)
  * @return VkAuthToken
  * @throws CDbException
  */
 protected function createToken()
 {
     // create ticket
     $ticket = new VkAuthTicket();
     $this->assertTrue($ticket->save(), json_encode($ticket->errors));
     $ticket->saveAttributes(['ip' => $this->ip]);
     // create token
     $token = new VkAuthToken();
     $token->attributes = ['auth_ticket' => $ticket->ticket, 'ip' => $this->ip, 'access_token' => $this->access_token, 'expires_in' => 0, 'user_id' => $this->user_id];
     $this->assertTrue($token->save(), json_encode($token->errors));
     return $token;
 }