php


reset password entered email in laravel 5.2 is case sensitive, make it insensitive


I am working on laravel5.2 project, i am using laravel's default auth module, which also provides us the reset password functionality.
I am facing issue in case if user is registered with
abcd#gmail.com
and if user enter email to reset password is
Abcd#gmail.com
In case of this it throws error account with this email doesn't exists.
As we can see both emails are same but just because of capitalization for first letter in second email it is throwing error.
How to make this functionality case insensitive?
Path of the file where searching email is Illuminate\Foundation\Auth\ResetsPasswords. But you don't want to edit this file. This file contain a php trait that use in PasswordController class.
So you can change the functionality of the trait methods by overriding it.
postEmail is the methods to be overwritten that find the user with given email and send reset link. Find the user by email case insensitively using ilike. Then overwrite request email variable by exact user email.
Following is to be the code in your PasswordController class (App\Http\Controllers\Auth\PasswordController)
public function postEmail(Request $request) {
$this->validate($request, ['email' => 'required|email']);
//Find the user by email case insensitively using ilike
$user = User::where('email', 'ilike', $request->email)->first();
// Overwrite request email variable by exact user email
$request->email = $user->email;
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
return redirect()->back()->with('status', trans($response));
case Password::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}

Related Links

Codeigniter custom language in input rules
PHP chained method, how to know wich is the last one
can't show my database in codeignaiter
Using newInstanceWithoutConstructor for alternative constructors
PHP convert date to mm-dd-YYYY to YYYY-mm-dd
Error updating record php mysql [closed]
PHP form: How not to send name of input if value empty? [duplicate]
How to GET parameters from AFNETWORKING POST
yii urlManager: if hide index.php, stop work rules
Error Parsing Data Org.Json.JSONException: End Of Input At Charac
Create and then directly load an image from a folder inline with HTML
+Testing an artisan command that edits the database
Implementing a job queue with rabbitmq
How can I edit navigation bar to take out a link when admin user signs in?
submit a form, but could not get input values
I'm not understanding something at PHP handling

Categories

HOME
google-chrome
macos-sierra
azure-functions
mpdf
shinyapps
applescript
enums
plaid
greasemonkey
static-analysis
cisco
msmq
trace32
sonicwall
hidden
scheduled-tasks
anova
maven-surefire-plugin
pymongo
rxjs5
ava
raima
openbravo
php-5.3
argv
caesar-cipher
xerces-c
testlink
netapp
opal-framework
robust
simple-schema
predicates
gmaps.js
mechanicalturk
kendo-treeview
openerp-6
bpms
msg
mathjs
polymerfire
flipclock
taco
vim-plugin
ioctl
dnx50
replicaset
componentart
erlog
whitespace-language
symja
ildasm
webmethod
accessory
incognito-mode
accountmanager
typesafe-stack
spring-security-acl
pbkdf2
ember-table
hints
sly-scroller
web-frameworks
tridion-2011
opends
firefly-mv
database-deadlocks
airprint
anonymous-types
bass
explicit
uninstaller
odac
gui-designer

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile