I was trying to implement basic user registration & login using ‘auth’. I am able to create the migrations and the tables are already created in the database as well.
When I fill up the registration details such as Name, Email, Password & Confirm Password and hit register, I’m landing up in this error:
This is the code in my .env file
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=townbakery DB_USERNAME=root DB_PASSWORD=12345678!
I’ve added any other code or have made any other changes except changing the Route web.php as
Route::get('/', function () { return view('auth.login'); }); Auth::routes(); Route::get('/home', 'HomeController@index')->name('home');
Please help me where I’ve gone wrong. This is the first application I’m working on after learning laravel basics.
Database.php looks like:
mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ],
Here is my User.php model:
<?php namespace App; use IlluminateNotificationsNotifiable; use IlluminateContractsAuthMustVerifyEmail; use IlluminateFoundationAuthUser as Authenticatable; class User extends Authenticatable { use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; }
Advertisement
Answer
One last possibility would be that your server is forcing the value of the env variable DB_PASSWORD
ether through Vhost or .htaccess
To verify this, try changing your .env
variable to DB_T_PASSWORD=12345678!
and dont forget to change it in database.php
config file 'password' => env('DB_T_PASSWORD', ''),