diff --git a/app/Http/Controllers/AuthenticationController.php b/app/Http/Controllers/AuthenticationController.php index 6c04fc0..7d8a51f 100644 --- a/app/Http/Controllers/AuthenticationController.php +++ b/app/Http/Controllers/AuthenticationController.php @@ -22,10 +22,11 @@ public function signUpStore(SignUpRequest $request) try { $user = new User; $user->name_en = $request->name; - $user->contact_en = $request->contact; + $user->contact_en = $request->contact_en; $user->email = $request->email; $user->password = Hash::make($request->password); $user->role_id = 4; + // dd($request->all()); if ($user->save()) return redirect('login')->with('success', 'Successfully Registered'); else @@ -46,7 +47,7 @@ public function signInCheck(SignInRequest $request) try { $user = User::where('contact_en', $request->username)->orWhere('email', $request->username)->first(); if ($user) { - if (Hash::check($request->password, $request->username)) { + if (Hash::check($request->password, $user->password)) { $this->setSession($user); return redirect()->route('dashboard')->with('success', 'Successfully Logged In'); } else diff --git a/app/Http/Helpers/index.php b/app/Http/Helpers/index.php index d11ecc6..dedb259 100644 --- a/app/Http/Helpers/index.php +++ b/app/Http/Helpers/index.php @@ -2,7 +2,7 @@ //Two way encryption method to encrypt sll data from url -function encryption($action, $string) +function encryptor($action, $string) { $output = false; diff --git a/app/Http/Requests/Authentication/SignInRequest.php b/app/Http/Requests/Authentication/SignInRequest.php index d340519..d41f4b9 100644 --- a/app/Http/Requests/Authentication/SignInRequest.php +++ b/app/Http/Requests/Authentication/SignInRequest.php @@ -11,7 +11,7 @@ class SignInRequest extends FormRequest */ public function authorize(): bool { - return false; + return true; } /** diff --git a/app/Http/Requests/Authentication/SignUpRequest.php b/app/Http/Requests/Authentication/SignUpRequest.php index 3dfaec8..05afe1f 100644 --- a/app/Http/Requests/Authentication/SignUpRequest.php +++ b/app/Http/Requests/Authentication/SignUpRequest.php @@ -11,7 +11,7 @@ class SignUpRequest extends FormRequest */ public function authorize(): bool { - return false; + return true; } /** @@ -22,10 +22,10 @@ public function authorize(): bool public function rules(): array { return [ - 'name'=>'required|max:255', - 'contact_en'=>'required|unique:users', - 'email'=> 'required|unique:users', - 'password'=>'required|confirmed', + 'name' => 'required|max:255', + 'contact_en' => 'required|unique:users', + 'email' => 'required|unique:users', + 'password' => 'required|confirmed', ]; } } diff --git a/app/Models/Role.php b/app/Models/Role.php index 42bb4d2..52be6a5 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -8,4 +8,9 @@ class Role extends Model { use HasFactory; + + // relation with user + public function users(){ + return $this->hasMany(User::class); + } } diff --git a/app/Models/User.php b/app/Models/User.php index 575e14e..1b864e6 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,9 +3,36 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Illuminate\Database\Eloquent\Model; +use Illuminate\Foundation\Auth\User as Authenticatable; +use Illuminate\Notifications\Notifiable; +use Laravel\Sanctum\HasApiTokens; +use Illuminate\Database\Eloquent\SoftDeletes; -class User extends Model +class User extends Authenticatable { - use HasFactory; + use HasFactory, HasApiTokens, Notifiable, SoftDeletes; + + // The attributes that are mass assignable. + protected $fillable = [ + 'name', + 'email', + 'password', + ]; + + // The attributes that should be hidden for serialization. + protected $hidden = [ + 'password', + 'remember_token', + ]; + + // The attributes that should be cast. + protected $casts = [ + 'email_verified_at' => 'datetime', + ]; + + // relation with role + public function role() + { + return $this->belongsTo(Role::class); + } } diff --git a/composer.lock b/composer.lock index d0fa49d..b49b837 100644 --- a/composer.lock +++ b/composer.lock @@ -505,24 +505,24 @@ }, { "name": "graham-campbell/result-type", - "version": "v1.1.1", + "version": "v1.1.2", "source": { "type": "git", "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "672eff8cf1d6fe1ef09ca0f89c4b287d6a3eb831" + "reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/672eff8cf1d6fe1ef09ca0f89c4b287d6a3eb831", - "reference": "672eff8cf1d6fe1ef09ca0f89c4b287d6a3eb831", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/fbd48bce38f73f8a4ec8583362e732e4095e5862", + "reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862", "shasum": "" }, "require": { "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.1" + "phpoption/phpoption": "^1.9.2" }, "require-dev": { - "phpunit/phpunit": "^8.5.32 || ^9.6.3 || ^10.0.12" + "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" }, "type": "library", "autoload": { @@ -551,7 +551,7 @@ ], "support": { "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.1" + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.2" }, "funding": [ { @@ -563,7 +563,7 @@ "type": "tidelift" } ], - "time": "2023-02-25T20:23:15+00:00" + "time": "2023-11-12T22:16:48+00:00" }, { "name": "guzzlehttp/guzzle", @@ -2317,16 +2317,16 @@ }, { "name": "phpoption/phpoption", - "version": "1.9.1", + "version": "1.9.2", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "dd3a383e599f49777d8b628dadbb90cae435b87e" + "reference": "80735db690fe4fc5c76dfa7f9b770634285fa820" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/dd3a383e599f49777d8b628dadbb90cae435b87e", - "reference": "dd3a383e599f49777d8b628dadbb90cae435b87e", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/80735db690fe4fc5c76dfa7f9b770634285fa820", + "reference": "80735db690fe4fc5c76dfa7f9b770634285fa820", "shasum": "" }, "require": { @@ -2334,7 +2334,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.32 || ^9.6.3 || ^10.0.12" + "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" }, "type": "library", "extra": { @@ -2376,7 +2376,7 @@ ], "support": { "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.9.1" + "source": "https://github.com/schmittjoh/php-option/tree/1.9.2" }, "funding": [ { @@ -2388,7 +2388,7 @@ "type": "tidelift" } ], - "time": "2023-02-25T19:38:58+00:00" + "time": "2023-11-12T21:59:55+00:00" }, { "name": "psr/clock", @@ -5413,31 +5413,31 @@ }, { "name": "vlucas/phpdotenv", - "version": "v5.5.0", + "version": "v5.6.0", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7" + "reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7", - "reference": "1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4", + "reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4", "shasum": "" }, "require": { "ext-pcre": "*", - "graham-campbell/result-type": "^1.0.2", - "php": "^7.1.3 || ^8.0", - "phpoption/phpoption": "^1.8", - "symfony/polyfill-ctype": "^1.23", - "symfony/polyfill-mbstring": "^1.23.1", - "symfony/polyfill-php80": "^1.23.1" + "graham-campbell/result-type": "^1.1.2", + "php": "^7.2.5 || ^8.0", + "phpoption/phpoption": "^1.9.2", + "symfony/polyfill-ctype": "^1.24", + "symfony/polyfill-mbstring": "^1.24", + "symfony/polyfill-php80": "^1.24" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", + "bamarni/composer-bin-plugin": "^1.8.2", "ext-filter": "*", - "phpunit/phpunit": "^7.5.20 || ^8.5.30 || ^9.5.25" + "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" }, "suggest": { "ext-filter": "Required to use the boolean validator." @@ -5449,7 +5449,7 @@ "forward-command": true }, "branch-alias": { - "dev-master": "5.5-dev" + "dev-master": "5.6-dev" } }, "autoload": { @@ -5481,7 +5481,7 @@ ], "support": { "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.5.0" + "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.0" }, "funding": [ { @@ -5493,7 +5493,7 @@ "type": "tidelift" } ], - "time": "2022-10-16T01:01:54+00:00" + "time": "2023-11-12T22:43:29+00:00" }, { "name": "voku/portable-ascii", diff --git a/database/migrations/2023_11_12_031415_create_roles_table.php b/database/migrations/2023_10_12_031415_create_roles_table.php similarity index 100% rename from database/migrations/2023_11_12_031415_create_roles_table.php rename to database/migrations/2023_10_12_031415_create_roles_table.php diff --git a/resources/views/Authentication/login.blade.php b/resources/views/Authentication/login.blade.php index 9927431..a1a13ba 100644 --- a/resources/views/Authentication/login.blade.php +++ b/resources/views/Authentication/login.blade.php @@ -1,57 +1,55 @@ @extends('layouts.appAuth') +@section('title', 'Log In') @section('content') - -
-
-
-
-
-
-
-
-

Sign in your account

-
- @csrf -
- - - @if($errors->has('username')) - {{$errors->first('username')}} - @endif -
-
- - - @if($errors->has('password')) - {{$errors->first('password')}} - @endif -
-
-
-
- - -
-
- -
-
- -
-
-