Welcome Guest, Not a member yet? Register   Sign In
Shield table auth_identities - fill column name
#1

(This post was last modified: 01-18-2023, 04:28 PM by groovebird.)

Hi,

how can i fill the column "name" if a new user will be registered or updated? I added the column in the array of user data but the column will not be filled. How can i solve this?
Reply
#2

Do you mean you want to add column "name" in the user table?
See https://github.com/codeigniter4/shield/discussions/333
Reply
#3

(01-18-2023, 06:01 PM)kenjis Wrote: Do you mean you want to add column "name" in the user table?
See https://github.com/codeigniter4/shield/discussions/333

No. The table auth_identites already has a column with the name of "name". After executing the migration this column exists.

I add a user like this:
https://codeigniter4.github.io/shield/qu...ting-users

With the following modification i wanted to fill this already existing column:

PHP Code:
$user = new User([
    
'username' => 'foo-bar',
    
'email'    => '[email protected]',
    
'password' => 'secret plain text password',
    
'name' => 'My Name' // i added this 
]); 

But the column "name" is still NULL. How can i fil this column?
Reply
#4

@kenjis, I think he needs to add the name field he added to the $allowedFields[] array.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(01-19-2023, 12:23 AM)InsiteFX Wrote: @kenjis, I think he needs to add the name field he added to the $allowedFields[] array.

@InsiteFX, the field is already there. This is the code from the UserIdentityModel:

PHP Code:
protected $allowedFields  = [
        
'user_id',
        
'type',
        
'name',
        
'secret',
        
'secret2',
        
'expires',
        
'extra',
        
'force_reset',
        
'last_used_at',
    ]; 
Reply
#6

(This post was last modified: 01-19-2023, 01:32 AM by kenjis.)

@groovebird
The name column in auth_identities
https://github.com/codeigniter4/shield/b...es.php#L37
is the name for the User Identitiy. 

For example, it is used for an Access Token.
See https://codeigniter4.github.io/shield/au...ess-tokens
You can set it ('Work Laptop' in the sample code) by $user->generateAccessToken().

See also https://codeigniter4.github.io/shield/co...identities
Reply
#7

If you want to do:
PHP Code:
$user = new User([
    'username' => 'foo-bar',
    'email'    => '[email protected]',
    'password' => 'secret plain text password',
    'name' => 'My Name' // i added this 
]); 

It seems better to add "name" column in "users" table.
Reply
#8

(This post was last modified: 01-19-2023, 02:01 AM by groovebird. Edit Reason: Question already answered above )

@kenjis ah ok.
Does it mean this is not really the column i can use for a name if not using the tokens? Do i have to add another column as you recommended in your first post?

EDIT: now i see you already answered to my question :-) Thank you!!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB