Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add user api #592

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

[WIP] Add user api #592

wants to merge 6 commits into from

Conversation

y3n4
Copy link
Contributor

@y3n4 y3n4 commented Apr 12, 2024

No description provided.

Copy link

sonarcloud bot commented Apr 12, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
17.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

Copy link
Contributor

@doobry-systemli doobry-systemli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks promising 😊 Didn't test and grap the JWT authentication yet. Left some comments on things that caught my eye.

$user = $this->security->getUser();

$aliases = $this->aliasHandler->getEnabledAliasesByUser($user);
$data = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use array_map here (and similarily in the other controllers) and return it directly. Something along the lines of:

return $this->json(array_map(function (Alias $alias) {
    return [
        'id' => $alias->getId(),
        'address' => $alias->getSource(),
        'isRandom' => $alias->getRandom(),
    ];
}, $aliases), 200);


$data=[
'username' => $user->getEmail(),
'mailcrypt_enabled' => $user->hasMailCrypt(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to expose this via the API? What would be the usecase for a selfservice client? Recovery token would be more useful and important, no?

@@ -2,8 +2,10 @@

namespace App\Traits;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These extra empty lines seem like leftovers?

@y3n4 y3n4 force-pushed the add_user_api branch 10 times, most recently from 082c759 to b4c91fa Compare April 21, 2024 16:14
#[Route('/api/user/aliases', name: 'get_user_aliases', methods: ['GET'])]
public function getAliases(): JsonResponse
{
$user = $this->security->getUser();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it work to use $this->getUser() directly from the parent AbstractController?

@y3n4 y3n4 added the enhancement New feature or request label Apr 22, 2024
@y3n4 y3n4 force-pushed the add_user_api branch 2 times, most recently from 74c99f4 to 43512fb Compare April 25, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants