Skip to content

Conversation

@jrushlow
Copy link
Collaborator

No description provided.

@jrushlow jrushlow added Feature New Feature Status: Needs Work Additional work is needed labels Nov 30, 2022
@jrushlow jrushlow force-pushed the feature/make-security-json-login branch from 4fe922a to 478077d Compare November 30, 2022 16:35
'@Symfony' => true,
'@Symfony:risky' => true,
'native_function_invocation' => false,
'blank_line_before_statement' => ['statements' => ['break', 'case', 'continue', 'declare', 'default', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'include', 'include_once', 'phpdoc', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield', 'yield_from']],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we need phpdoc to be added... TODO: check whats included in symfony rules set and only add the one we need.

Copy link
Collaborator Author

@jrushlow jrushlow Dec 1, 2022

Choose a reason for hiding this comment

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

im using our test config here because, well lazy is cool, but thinking we either duplicate this for generating templates or rename / move this away from "test" and still use it for both ci and generating templates. See CI failures related to other makers as a result of the added rule.

@jrushlow jrushlow force-pushed the feature/make-security-json-login branch from a692b79 to 8432cf1 Compare December 15, 2022 04:37
@jrushlow jrushlow marked this pull request as ready for review December 15, 2022 19:19
Comment on lines -18 to 19

// last username entered by the user
/** last username entered by the user */
$lastUsername = $authenticationUtils->getLastUsername();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

php-cs-fixer does not have the capability to add a space above a comments (//) but it can do it with docblocks (/** */)

Without changing the comments over, we would end up with:

        // get the login error if there is one
        $error = $authenticationUtils->getLastAuthenticationError();
        // last username entered by the user
        $lastUsername = $authenticationUtils->getLastUsername();

which could be alright?

$this->userNameField = $securityHelper->guessUserNameField($io, $this->userClass, $securityData['security']['providers']);
$this->willLogout = $io->confirm('Do you want to generate a \'/logout\' URL?');
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could probably find more repeated code between make:json & make:form logins if we looked hard enough...

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

Looking great!

'Choose a name for the controller class (e.g. <fg=yellow>ApiLoginController</>)',
'ApiLoginController',
[Validator::class, 'validateClassName']
);
Copy link
Member

Choose a reason for hiding this comment

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

This question and the suggestion of ApiLoginController are in the abstract security maker?

public function configureDependencies(DependencyBuilder $dependencies): void
{
$dependencies->addClassDependency(SecurityBundle::class, 'security');
$dependencies->addClassDependency(Process::class, 'process');
Copy link
Member

Choose a reason for hiding this comment

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

Is this actually needed?

'use_statements' => $useStatements,
'controller_name' => $controllerNameDetails->getShortName(),
]
);
Copy link
Member

Choose a reason for hiding this comment

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

This could be a new generateEmptyController() on Generator 🤔

$this->writeSuccessMessage($io);

$io->text([
'Next: Make a <info>POST</info> request to <info>/api/login</info> with a <info>username</info> and <info>password</info> to login.',
Copy link
Member

Choose a reason for hiding this comment

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

The user also needs to set Content-Type: application/json iirc. This is sometimes a "gotcha", so it would be nice to mention it here.

@@ -0,0 +1,11 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

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

The _L (capital L) looks weird, but I can see you did that on purpose. What was the reason?


$this->addUseStatements($manipulator, [Route::class]);

$methodBuilder->addParam((new Param('authenticationUtils'))->setType('AuthenticationUtils'));
Copy link
Member

Choose a reason for hiding this comment

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

Will there already be a use statement for this? In addLoginMethod(), we explicitly add the use statement.

(new Param('user'))
->setType(new NullableType($userClass->getShortName()))
->addAttribute(new Attribute(new Name('CurrentUser')))
);
Copy link
Member

Choose a reason for hiding this comment

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

This probably needs to change to $this->getUser() for better "portability" across all versions of Symfony, DoctrineBundle, FWEXtra, etc?

Copy link
Collaborator Author

@jrushlow jrushlow Dec 16, 2022

Choose a reason for hiding this comment

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

Should we bother making that conditional based on the Symfony Version? Or perhaps we do that (CurrentUser) later when say 6.4 or 7 come out for less of a headache for us

@jrushlow jrushlow force-pushed the feature/make-security-json-login branch from 96cc0d3 to df01550 Compare May 23, 2023 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New Feature Status: Needs Work Additional work is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants