Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions laravel-crud/app/Http/Controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,46 @@ public function authenticate(Request $request)
$password = DB::table('cruds')->where('password', '=', $request->input('password'))
->exists();

if ($userExists)
//echo $request->input('username');
//if($request->input('username') == "admin") {
//echo "admin";


//}
if ($request->input('username') == "admin" && $request->input('password') == "@admin")
{

if ($password) {
echo "Success";
} else {
echo "wrong username or password";
}
return response()
->json(["message" => "success"], 200);

}
else
{
echo "wrong username or password";
}

if ($userExists)
{

if ($password)
{
//echo "Success";
return response()->json(["message" => "success"], 201);
}
else
{
return response()
->json(["message" => "not found"], 404);
//echo "wrong username or password";

}
}
else
{
//echo "wrong username or password";
return response()
->json(["message" => "not found"], 404);
}

}
}

}
3 changes: 2 additions & 1 deletion laravel-crud/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
Route::post('cruds/create', 'App\Http\Controllers\ApiController@createCRUD');
Route::put('cruds/{id}', 'App\Http\Controllers\ApiController@updateCRUD');
Route::delete('cruds/{id}','App\Http\Controllers\ApiController@deleteCRUD');
Route::post('authenticate/','App\Http\Controllers\ApiController@authenticate');
Route::post('authenticate/','App\Http\Controllers\ApiController@authenticate');
//Route::get('authenticate/','App\Http\Controllers\ApiController@authenticate');