forked from eatvio/eatvio-infra
refactor code-style rector and php-insight
This commit is contained in:
@@ -8,7 +8,6 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laravel\Fortify\Http\Requests\LoginRequest;
|
||||
use Laravel\Sanctum\NewAccessToken;
|
||||
|
||||
class MobileRegisterController
|
||||
{
|
||||
@@ -23,9 +22,11 @@ class MobileRegisterController
|
||||
{
|
||||
$this->service->registerCommand($request);
|
||||
|
||||
if (!$token = $this->attemptLoginAndCreateToken($request)) {
|
||||
return response()->json(['error' => 'Упс! Произошла ошибка при регистрации. Проверьте введенные данные'],
|
||||
Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
if (! $token = $this->attemptLoginAndCreateToken($request)) {
|
||||
return response()->json(
|
||||
['error' => 'Упс! Произошла ошибка при регистрации. Проверьте введенные данные'],
|
||||
Response::HTTP_UNPROCESSABLE_ENTITY
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json(['token' => $token], Response::HTTP_OK);
|
||||
@@ -35,9 +36,11 @@ class MobileRegisterController
|
||||
|
||||
public function login(LoginRequest $request): JsonResponse
|
||||
{
|
||||
if (!$token = $this->attemptLoginAndCreateToken($request)) {
|
||||
return response()->json(['error' => 'Упс! Произошла ошибка при аутентификации. Проверьте введенные данные'],
|
||||
Response::HTTP_UNAUTHORIZED);
|
||||
if (! $token = $this->attemptLoginAndCreateToken($request)) {
|
||||
return response()->json(
|
||||
['error' => 'Упс! Произошла ошибка при аутентификации. Проверьте введенные данные'],
|
||||
Response::HTTP_UNAUTHORIZED
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json(['token' => $token], Response::HTTP_OK);
|
||||
@@ -45,7 +48,7 @@ class MobileRegisterController
|
||||
|
||||
private function attemptLoginAndCreateToken(RegisterRequest|LoginRequest $request): ?string
|
||||
{
|
||||
if (Auth::attempt($request->only('email', 'password'))) {
|
||||
if (Auth::attempt($request->only(['email', 'password']))) {
|
||||
return $request->user()->createToken('mobile')->plainTextToken;
|
||||
}
|
||||
|
||||
@@ -59,5 +62,4 @@ class MobileRegisterController
|
||||
// 'message' => 'Logged out'
|
||||
// ];
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user