Comments (2)
Hi! I agree with (3), this seems an irrelevant to mention in this particular example. Let's remove the text and leave just // ...
.
As for your other 2 questions: I would say it's good to validate user input related to authentication explicitly if it confirms the rules of your application, rather than relying on "implementation details" of the Symfony framework.
This is also an approach we use in the build-in Symfony authenticators (we recently added it for form login: symfony/symfony#53851).
Throwing an authentication exception is the best solution, this will give the validation the same handling as other authentication error messages like "bad credentials" (i.e. call the onAuthenticationFailure()
method of the current authenticator, which then has some way to return the error to the client).
from symfony-docs.
Sorry, I wasn't aware that an exception in this context isn't really thrown, but caught by the next method. So raising an exception is indeed the way to go!
So I think this code snippet should be expanded to something like:
if ('' === $username || '' === $password) {
throw new WhateverException();
}
But where to put it?
This page is missing a full example of a form login. This is due to the fact that there cannot be a full example for every possible setup. But: When introducing the sub-headings (as I suggested in #19813 (comment) ), the new section under authenticate()
would be the perfect place!
So in case you're already losing overview of what I have in mind ;-)
Should I create one big PR for everything on this page, or try to do it in smaller steps?
from symfony-docs.
Related Issues (20)
- [Validator] Add `errorPath` to Unique constraint HOT 1
- [UX] Make symfony.com/ux redirect to current version ? HOT 2
- "/components" returns 500 response status code HOT 1
- [Messenger] Add `--format` option to the `messenger:stats` command HOT 1
- [Validator] Add the `format` option to the `Ulid` constraint to allow a…
- [ExpressionLanguage] Add comment support to expression language HOT 1
- [DependencyInjection] Add `#[WhenNot]` attribute HOT 1
- Unify how --format is handled by commands HOT 1
- SVG images don't work on 5.X version HOT 1
- Ibexa is sponsoring Symfony 5.4, thanks to them! \o/
- [Messenger] Introduce `#[AsMessage]` attribute for message routing
- [HtmlSanitizer] Add support for configuring the default action
- [Config] Purpose and Misusage of Component HOT 8
- Improve the TypeInfo docs HOT 1
- [String] Add `TruncateMode` mode to `truncate` methods HOT 1
- [Notifier] Add Sipgate bridge HOT 1
- [Notifier] Remove the Gitter bridge HOT 1
- [FrameworkBundle] Add `exit` option to `secrets:decrypt-to-local` comma… HOT 3
- [SecurityBundle] Link to the profile the token was (de)authenticated HOT 2
- [Upload files] parameter or bind? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from symfony-docs.