4 ms·
Coming from Django , I was surprised rails 5.1 didn't come with authentication / authorization (or a valid email regexp) I will definitely use this!
by abledon 9y ago
Coming from Django , I was surprised rails 5.1 didn't come with authentication / authorization (or a valid email regexp)
I will definitely use this!
- aleyan 9y agoComing to Django, if you want to do auth via email instead of username, you are out of batteries. I say this criticism as a fan of both Django and Rails.
- gjjrfcbugxbhf 9y agoIt's about 20 loc to implement this in Django... Edit: problem is that when starting a new project people often miss those 20 loc - as well as not noticing the documented best practices for accessing the user...
- abledon 9y agoyeah, but i think by mentioning 'batteries' it means __no__ code is needed, simply a change in a config setting / changing a string to say.. 'username'-> 'email' somewhere.
- abledon 9y agoHow do you like Django's DB migration system, how it will autogenerate ManyToMany tables etc.. i was astounded how much manual code is needed: http://jeffthomas.xyz/many-to-many-relationships-in-rails http://jeffthomas.xyz/many-to-many-relationships-in-rails
- mbell 9y ago> (or a valid email regexp) I don't believe such a thing exists.
- abledon 9y agowell, I enjoyed their attempt: https://docs.djangoproject.com/en/1.11/_modules/django/core/validators/#EmailValidator https://docs.djangoproject.com/en/1.11/_modules/django/core/...
- majewsky 9y agoIt looks better than most attempts I've seen, but there is an actual pedantically standards-compliant regex. I think it's somewhere on Stack Overflow, and its character count has five digits.
- mnarayan01 9y ago> or a valid email regexp In terms of standards, there's not a whole lot you can do beyond validate the domain if it includes one. You can take the HTML5 approach (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#Basic_validation https://developer.mozilla.org/en-US/docs/Web/HTML/Element/in...), but that means leaving out at least theoretically valid email addresses.
- majewsky 9y agoHuh? RFC 2822 describes in detail what a valid email address looks like. (There might be newer ones superseding it; that's the one that was current back when I looked into this topic.) In practice, a lot of theoretically valid email addresses are rejected by implementations, e.g. my favorite: "@"@example.com What's true, of course, is that you should never rely on an email address being syntactically correct. You should only use it after having done a validation process that involves sending mail to that address.
- mnarayan01 9y agoI agree with everything you're saying (though my favorite is probably addresses containing newlines). My point is just that in practice it's not terribly useful, e.g. why HTML5 defines its own: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address https://html.spec.whatwg.org/multipage/input.html#valid-e-ma....
- jph 9y agoRuby email validation gem: https://github.com/SixArm/sixarm_ruby_email_address_validation https://github.com/SixArm/sixarm_ruby_email_address_validati... Feedback welcome. I'm the contact person for the gem.