Hi.こんにちわ。
I’m using the AuthenticationPlugin for CakePHP4. I use a routing prefix to separate the admin screen and the normal screen, but the normal user can come and go between the admin screen and the normal screen freely.
So we want to get the model used and redirect to the 404 screen when the model is not used in the admin screen.
It’s a long story. Let’s get to the point.
This will give you the users email address you are logged in to.
$this->Authentication->getIdentity()->mail
Now you can get the users name you are logged in with.
$this->Authentication->getIdentity()->name
So how do I get information about the model I’m using as a logged in user?
???
.
.
.
This is when output by “dd($this->Authentication->getIdentity());”.
Authentication\Identity {#116 ▼
....
#_registryAlias: "Users"
id: 3
name: "test_user_name"
mail: "test@test.co.jp"
password: "$2y$10$POv4UXil1mR/cWWBDlNkTu2mw2d8c7GTNdAOZRFYi03T8tk8m8O4S"
sso: 0
provider_cd: 0
provider_id: null
points: 0
created: Cake\I18n\FrozenTime @1599105798 {#119 ▶}
updated: Cake\I18n\FrozenTime @1599105798 {#120 ▶}
[new]: false
[accessible]: array:9 [▶]
[dirty]: []
[original]: []
[virtual]: []
[hasErrors]: false
[errors]: []
[invalid]: []
[repository]: "Users"
How do I extract the value of [repository] again?
Plz Helpe Me!!