I can't log in via username and password which was created programmatically using code, but when I reset the password via the admin page it's working perfectly.
To replicate the issue, the following can be done:
1. Add a script to create a user in your test module:
<?php
use Drupal\user\Entity\User;
// Create a new user.
$user = User::create([
'name' => 'username',
'mail' => 'email@example.com',
'pass' => 'password',
'status' => 1,
'roles' => ['authenticated'],
]);
// Save the user.
$user->save();
2. Try logging in with the newly created user info
Comments
Comment #2
chi commentedThis needs steps to reproduce.
Comment #3
cilefen commentedComment #4
cilefen commentedComment #5
enaznin commentedUpdated the IS.
Comment #6
enaznin commentedUpdated the IS
Comment #7
cilefen commentedI cannot reproduce this. Your code works.
I put it in a file named test.php and executed it like
vendor/bin/drush php:script test.php. The user can log in.Comment #8
shiv_sharma commentedNot able to reproduce this issue.
Tried with two ways.
1. Added the code on submit handler its created the user and able to access the site with same credentials.
2. From DevelPHP just execute your code work fine here too.
Could you explain your issue which can help us to explore more..
Comment #9
cilefen commentedThere reporter has not replied.