JWTRefreshTokenBundle icon indicating copy to clipboard operation
JWTRefreshTokenBundle copied to clipboard

custom refresh token column username

Open ujikstark opened this issue 3 years ago • 4 comments

hello everyone. i want to change the column of username in table refresh_tokens with email. i code like below it's not work

gesdinet_jwt_refresh_token:
    user_identity_field: email

and do you have a any option for that ? i have created a custom entity use like this

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken;

/**
 * This class extends Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken to have another table name.
 *
 * @ORM\Table("jwt_refresh_token")
 */
class JwtRefreshToken extends RefreshToken
{
}

and add

gesdinet_jwt_refresh_token:
    refresh_token_class: App\Entity\JwtRefreshToken

and when i typed like below it doen't have sql query to created that custom table

php bin/console doctrine:schema:update --dump-sql

ujikstark avatar Jan 04 '22 04:01 ujikstark

Setting the user_identity_field config has no practical use anymore; in fact, that config node is deprecated.

As for changing the column name (or database schema in general), keep an eye on #285 as some issues are being discussed there. Also keep in mind that if you do change any of the column names, you will have to replace other services as well (i.e. you'll need an extended version of the Doctrine RefreshTokenManager as its getLastFromUsername() method does a database query using the "username" column).

mbabker avatar Jan 05 '22 16:01 mbabker

The 1.1 release should have fixed this.

mbabker avatar Apr 11 '22 14:04 mbabker

Hi, I am using this version 1.1 with Symfony 5.4 and I still can't change the "user_identity_field". I tried using this function in my User Entity => public function getUserIdentifier(): string { return (string) $this->id;//email }

The refresh token is created and I have the ID in the column "username" of the database, but when I want to refresh the token I have this message => 401 "Invalid credentials"

I change the Yaml config in Security.yaml but nothing change : app_user_provider: entity: class: App\Entity\User property: id

Is there any way to solve this problem ? Thanks !

Echoju avatar Apr 21 '22 01:04 Echoju

Same issue here ... v1.1 SF6 and user_identity_field has no effect :(

[edit] ->scalarNode('user_identity_field') ->setDeprecated(...$this->getDeprecationParameters('The "%node%" node is deprecated without replacement.', '1.0')) ->defaultValue('username') 👎

AimSai59 avatar Aug 05 '22 02:08 AimSai59