Skip to content

Commit

Permalink
useless http login added on the client side
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdusshakur committed Jan 23, 2023
1 parent 515c243 commit 34eb837
Show file tree
Hide file tree
Showing 13 changed files with 367 additions and 10 deletions.
138 changes: 138 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/phpunit.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 119 additions & 1 deletion .idea/todoapp.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions app/Http/Controllers/Api/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\User;
use Illuminate\Validation\Rules;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;

class UserController extends Controller
Expand Down Expand Up @@ -54,6 +55,23 @@ public function store(Request $request)
]);
}


public function login(Request $request)
{
if(Auth::attempt(['email' => $request->email, 'password' => $request->password])){

return response()->json([
'message' => 'User Account Created Successfully',
'userName' => Auth::user()->name,
]);
}
else{
return response()->json([
'message' => 'Unauthorised'
]);
}
}

/**
* Display the specified resource.
*
Expand Down
34 changes: 34 additions & 0 deletions app/Http/Controllers/LoginWithApiController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Http;

class LoginWithApiController extends Controller
{
public function index(Request $request)
{
$http = new \GuzzleHttp\Client();

$response = $http->post('http://127.0.0.1:8000/api/login', [
'form_params' => [
'email' => '[email protected]',
'password' => 'panda1221',
]
]);

return "ddd";
}

public function register(Request $request)
{


Http::post('http://127.0.0.1:8000/api/users', [
'email' => $request->get('email'),
'password' => Hash::make($request->get('password'))
]);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"php": "^8.0.2",
"guzzlehttp/guzzle": "^7.2",
"guzzlehttp/guzzle": "^7.5",
"laravel/framework": "^9.19",
"laravel/sanctum": "^3.0",
"laravel/tinker": "^2.7",
Expand Down
Loading

0 comments on commit 34eb837

Please sign in to comment.