我有AuthController
public function register(Request $request)
{
$user = UserSistem::create([
'username' => $request->username,
'nama' => $request->nama,
'email' => $request->email,
'password_secret' => bcrypt($request->password)
]);
$token = auth()->login($user);
return $this->respondWithToken($token);
}
public function login(Request $request)
{
$credentials = $request->only(['email', 'password']);
if (!$token = auth()->attempt($credentials)) {
return response()->json(['error' => 'Unauthorized'], 401);
}
return $this->respondWithToken($token);
}
protected function respondWithToken($token)
{
return response()->json([
'access_token' => $token,
'token_type' => 'bearer'
]);
}
register
function 是工作,但不是 for login
,我应该使用password
column 而不是password_secret
in register
function,因为我尝试使用password
column 并且工作正常吗?
如何password_secret
在函数中使用有效载荷上的列register
?