Fix registration call.

このコミットが含まれているのは:
テクニカル諏訪子 2018-03-16 00:55:57 +09:00
コミット 6a5b75abff
1個のファイルの変更13行の追加2行の削除

ファイルの表示

@ -182,7 +182,7 @@ class AuthController extends Controller {
}
public function register(Request $request) {
$credentials = $request->only('username', 'password');
$credentials = $request->only('username', 'email', 'password');
$rules = [
'username' => 'required|max:255|unique:users',
@ -209,7 +209,18 @@ class AuthController extends Controller {
'gender' => $gender
]);
return $this->login($request);
try {
// attempt to verify the credentials and create a token for the user
if (!$token = JWTAuth::attempt($credentials)) {
return response()->json(['success' => false, 'error' => 'We cant find an account with this credentials.'], 401);
}
}
catch (JWTException $e) {
// something went wrong whilst attempting to encode the token
return response()->json(['success' => false, 'error' => 'Failed to login, please try again.'], 500);
}
// all good so return the token
return response()->json(['success' => true, 'data'=> [ 'token' => $token ]]);
}
/**