Skip to content

Commit f13a34a

Browse files
committed
[Experimental] Fix user transformation and update tests for 2FA and identifier attributes
1 parent 5b0da34 commit f13a34a

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

app/Transformers/Api/Client/UserTransformer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public function transform(User $model): array
3030
'email' => $model->email,
3131
'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($model->email)),
3232
// which do we prefer?
33-
'admin' => (bool) $user->root_admin,
34-
'root_admin' => (bool) $user->root_admin,
35-
'2fa_enabled' => $model->use_totp,
33+
'admin' => (bool) $model->root_admin,
34+
'root_admin' => (bool) $model->root_admin,
35+
'2fa_enabled' => (bool) $model->use_totp,
3636
'first_name' => $model->name_first,
3737
'last_name' => $model->name_last,
3838
'language' => $model->language,
39-
'created_at' => $this->formatTimestamp($user->created_at),
40-
'updated_at' => $this->formatTimestamp($user->updated_at),
39+
'created_at' => $this->formatTimestamp($model->created_at),
40+
'updated_at' => $this->formatTimestamp($model->updated_at),
4141
];
4242
}
4343
}

tests/Integration/Api/Application/Users/UserControllerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public function testGetUsers()
5656
'last_name' => $this->getApiUser()->name_last,
5757
'language' => $this->getApiUser()->language,
5858
'root_admin' => $this->getApiUser()->root_admin,
59-
'2fa_enabled' => (bool) $this->getApiUser()->totp_enabled,
60-
'2fa' => (bool) $this->getApiUser()->totp_enabled,
59+
'2fa_enabled' => (bool) $this->getApiUser()->use_totp,
60+
'2fa' => (bool) $this->getApiUser()->use_totp,
6161
'created_at' => $this->formatTimestamp($this->getApiUser()->created_at),
6262
'updated_at' => $this->formatTimestamp($this->getApiUser()->updated_at),
6363
],
@@ -74,8 +74,8 @@ public function testGetUsers()
7474
'last_name' => $user->name_last,
7575
'language' => $user->language,
7676
'root_admin' => (bool) $user->root_admin,
77-
'2fa_enabled' => (bool) $user->totp_enabled,
78-
'2fa' => (bool) $user->totp_enabled,
77+
'2fa_enabled' => (bool) $user->use_totp,
78+
'2fa' => (bool) $user->use_totp,
7979
'created_at' => $this->formatTimestamp($user->created_at),
8080
'updated_at' => $this->formatTimestamp($user->updated_at),
8181
],

tests/Integration/Api/Client/AccountControllerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function testAccountDetailsAreReturned()
2727
'attributes' => [
2828
'id' => $user->id,
2929
'uuid' => $user->uuid,
30+
'identifier' => $user->identifier,
3031
// TODO: pick one or keep both
3132
'admin' => false,
3233
'root_admin' => false,

0 commit comments

Comments
 (0)