<?php
namespace common\modules\eauth\components;

/**
 * Trait extends functionality of nodge\eauth\BaseService class in extension "yii2-eauth"
 */
trait ServiceTrait
{
    protected $socialProfile;

    /**
     * Logout from Oauth
     */
    public function logout()
    {
        $this->getProxy()->getStorage()->clearToken($this->getServiceName());
    }

    public function getSocialProfile()
    {
        return $this->socialProfile;
    }

    public function setSocialProfile($profile)
    {
        $this->socialProfile = $profile;
    }

    public function checkAttributes()
    {
        if (!$this->socialProfile['email']) {
            die('Невозможно получить email');
        }
    }
}
