User.php 739 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace fphammerle\yii2\auth\clientcert\tests\models;
  3. class User extends \yii\db\ActiveRecord
  4. implements \yii\web\IdentityInterface
  5. {
  6. public static function tableName()
  7. {
  8. return 'user';
  9. }
  10. public static function findIdentity($id)
  11. {
  12. return static::findOne(['id' => $id]);
  13. }
  14. public static function findIdentityByAccessToken($token, $type = null)
  15. {
  16. throw new NotSupportedException();
  17. }
  18. public function getId()
  19. {
  20. return $this->primaryKey;
  21. }
  22. public function getAuthKey()
  23. {
  24. return sprintf('auth-key-%d', $this->id);
  25. }
  26. public function validateAuthKey($authKey)
  27. {
  28. return $this->getAuthKey() === $authKey;
  29. }
  30. }