I followed the instructions to set up Laravel passport. A user table and other tables have been created. I copied a tutorial file for a register controller. I am receiving a success message in postman but no required data was entered and it is not doing any validation. Is there anything else I need to do?
<?php
namespace App\Http\Controllers\Api;
use App\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class AuthController extends Controller
{
public function register(Request $request)
{
$validatedData = $request->validate([
'name'=>'required|max:55',
'email'=>'email|required|unique:users',
'password'=>'required|confirmed'
]);
$validatedData['password'] = bcrypt($request->password);
$user = User::create($validatedData);
$accessToken = $user->createToken('authToken')->accessToken;
return response(['user'=> $user, 'access_token'=> $accessToken]);
}
Route::post('/register', 'Api\AuthController@register');
Route::post('/login', 'Api\AuthController@login');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire