|
|
|
@ -8,7 +8,9 @@ use Illuminate\Support\Facades\Hash;
|
|
|
|
|
|
|
|
|
|
use App\Models\User; |
|
|
|
|
use App\Models\Role; |
|
|
|
|
|
|
|
|
|
use Illuminate\Http\JsonResponse; |
|
|
|
|
use Illuminate\Support\Facades\Password; |
|
|
|
|
use Illuminate\Validation\ValidationException; |
|
|
|
|
class AuthController extends Controller |
|
|
|
|
{ |
|
|
|
|
public function __construct() |
|
|
|
@ -26,8 +28,17 @@ class AuthController extends Controller
|
|
|
|
|
if(empty($username) || empty($password)) |
|
|
|
|
return response()->json(['status'=>'error','message'=>'You must fill all the fields'], 400); |
|
|
|
|
|
|
|
|
|
$user = User::where('username', $username)->where('password', md5($password))->first(); |
|
|
|
|
$usernameCheck = false; |
|
|
|
|
$passwordCheck = false; |
|
|
|
|
|
|
|
|
|
if (User::where('username', $username)->exist()) |
|
|
|
|
$usernameCheck = true; |
|
|
|
|
|
|
|
|
|
if (User::where('password', md5($password))->exists()) |
|
|
|
|
$passwordCheck = true; |
|
|
|
|
|
|
|
|
|
if ($usernameCheck & $passwordCheck){ |
|
|
|
|
$user = User::where('username', $username)->where('password', md5($password))->first(); |
|
|
|
|
if($is_mobile){ |
|
|
|
|
$fcm_token = $request->fcm_token; |
|
|
|
|
|
|
|
|
@ -69,5 +80,13 @@ class AuthController extends Controller
|
|
|
|
|
'expires_in' => auth()->factory()->getTTL() * $ttl, |
|
|
|
|
), |
|
|
|
|
]); |
|
|
|
|
}else { |
|
|
|
|
if (!$usernameCheck && !$passwordCheck) |
|
|
|
|
return response()->json(['code' => 201, 'message' => "username and password doesn't match"], 201); |
|
|
|
|
if (!$passwordCheck) |
|
|
|
|
return response()->json(['code' => 201, 'message' => "password doesn't match"], 201); |
|
|
|
|
if (!$usernameCheck) |
|
|
|
|
return response()->json(['code' => 201, 'message' => "username doesn't match"], 201); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|