Hello, I get this message every time I register a new user with a password that is not alphabetic and lowercase.
Error :
{"error":"invalid_credentials","message":"The user credentials were incorrect."}
Http/Controllers/Api/Auth/RegisterController
class Registercontroller extends Controller
{
private $client;
public function __construct(){
$this->client = Client::find(1);
}
//register new user
public function register(Request $request)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required|email|unique:users,email',
'password' => 'required|min:6|confirmed'
]);
$user = User::create([
'name' => request('name'),
'email' => request('email'),
'password' => bcrypt('password')
]);
$params =[
'grant_type' => 'password',
'client_id' => $this->client->id,
'client_secret' => $this->client->secret,
'username' => request('email'),
'password' => request('password'),
'scope' => '*'
];
$request->request->add($params);
$proxy = Request::create('oauth/token', 'POST');
return Route::dispatch($proxy);
}
}
Working register request :
Method : POST
username: test
email: test@test.com
password: password
password_confirmation: password
Response :
{
"token_type": "Bearer",
"expires_in": 1296000,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjdmNmM0NjFiY2JlYjdiZWEzNmNiYmFjMjQyYWRjNWY3Y2ZmZDJjMGQ2NjZkNDAwNGY5MWRiYzRjN2NhNTA4NjIwYTRlZWZhMzFiMDEzZGJjIn0.eyJhdWQiOiIxIiwianRpIjoiN2Y2YzQ2MWJjYmViN2JlYTM2Y2JiYWMyNDJhZGM1ZjdjZmZkMmMwZDY2NmQ0MDA0ZjkxZGJjNGM3Y2E1MDg2MjBhNGVlZmEzMWIwMTNkYmMiLCJpYXQiOjE1NDMzMTIxNTQsIm5iZiI6MTU0MzMxMjE1NCwiZXhwIjoxNTQ0NjA4MTU0LCJzdWIiOiI3OCIsInNjb3BlcyI6WyIqIl19.oq38hmdUjLFo2HYMHRE4pxzV9ey7sKpe7q4RJoCdI3pH0rM59kM88KCKmJ84p9kUwCCL_-re4W9j_NKcQUbN5USI4p5MsNXYm6P_JnX7lM3zDkjHMP621Jk8AjsbtpgP3fT4uaVUvs478hylImfjVCXB1U54KWYTHJ-6C8RSgUXGmdkHtHQiIkz-qxuHUVCkZ73Lg7yA4ul4dL_h8EmGtu_Dh63qQhzWKciD95wKpCccXfPw7xCAgOgaKt7DSLX4z-sUcd_Fdmo7G4f4PxvrbTLLNNb5VXTkzdDHe83MM8npcfMwKJGvz8VMb3ddiPeRu1fwHnrmd_jbLlpI7CP9IohZQXFBQFpH2DEmaoxPRTgL1tbSWWkvZnuTvlirdVEPSYk5mexQEq8mk1p6R2O9jNARawRNVFtnf9GuOupcfymKsvx2KWRJtqhgClGkLr_xxo0KlVcf4Ah6vH43UVrqN2L7Sl3KLF662FnDnv1kN9LWiIE6WoJj2XaqCi4AsQFRrWRGkDHKd5hjchgVJN9mN5CPYHjHQdn-rS2z1gU7o2uRB45GXU0H6oYaJIEulLiuettCeHX9P55b2XTYIMefXr69k5gc6zaI1YwmUROqKjOa2VAAxN_23bKmbk4HXF6_LWodNcs13MURlazrFu8sv37bKwjDzaCGhvOglgukwLM",
"refresh_token": "def502004acb5bd264455ebf46deb658ad8105ae55b33642a2c12ada76b30f9a8fead43a5c8e644d181c0909f41f45376e75edea5c401a1d28cb7966c8e0cdd8f17bdbedec2ed57c3aafed3e26ef1dc0898f940f7c7a98432710cf47a4c33bf737ce2b9d5e8a5b2e6f263885638c4988722e5971640daeb2116b0a43759ea82c2811a89e789c0000af5d3f9e53e1847af09b2d7c52b0aa3cdb0c477aa50fd1b32820eacd132e253c427c4500f48caee49ef1d7de6b3be6fd7d1d49e772578ddf91d1e7ad74bed2aea7450f315c17df686bae0d523233494ceedad774f1649f3e78bcf88d210c8f73b2faf4f7414558c4d6035e8845bdb5e2b64c86dab7f0246c06137c4d8c6288b04b2dea4b352bfb1fef9e07fd68ec7a62a197c6c1d304bec13c13aa0cd31c9c31bf1a536ee67fe754cee4a4afb17ce1af951aafe4057a58e111ac03d03abc766ef177326694ed16a88a2d88ab54a5598fd515c44aa39984b263baf65de3"
}
Not working register request :
Method : POST
username: test
email: test@test.com
password: password123
password_confirmation: password123
Response :
{"error":"invalid_credentials","message":"The user credentials were incorrect."}
How to solve this please ?
Error in RegisterController, it had to change
'password' => bcrypt('password')
to
'password' => bcrypt(request('password'))
Thanks to poboy from Official Laravel IRC.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community