-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from teamq-ec/main
main
- Loading branch information
Showing
12 changed files
with
777 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
APP_NAME=Laravel | ||
APP_ENV=local | ||
APP_KEY= | ||
APP_DEBUG=true | ||
APP_URL=http://localhost | ||
|
||
LOG_CHANNEL=stack | ||
LOG_DEPRECATIONS_CHANNEL=null | ||
LOG_LEVEL=debug | ||
|
||
DB_CONNECTION=mysql | ||
DB_HOST=127.0.0.1 | ||
DB_PORT=3306 | ||
DB_DATABASE=appliance_care | ||
DB_USERNAME=root | ||
DB_PASSWORD= | ||
|
||
BROADCAST_DRIVER=log | ||
CACHE_DRIVER=file | ||
FILESYSTEM_DISK=local | ||
QUEUE_CONNECTION=sync | ||
SESSION_DRIVER=file | ||
SESSION_LIFETIME=120 | ||
|
||
MEMCACHED_HOST=127.0.0.1 | ||
|
||
REDIS_HOST=127.0.0.1 | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 | ||
|
||
MAIL_MAILER=smtp | ||
MAIL_HOST=mailpit | ||
MAIL_PORT=1025 | ||
MAIL_USERNAME=null | ||
MAIL_PASSWORD=null | ||
MAIL_ENCRYPTION=null | ||
MAIL_FROM_ADDRESS="[email protected]" | ||
MAIL_FROM_NAME="${APP_NAME}" | ||
|
||
AWS_ACCESS_KEY_ID= | ||
AWS_SECRET_ACCESS_KEY= | ||
AWS_DEFAULT_REGION=us-east-1 | ||
AWS_BUCKET= | ||
AWS_USE_PATH_STYLE_ENDPOINT=false | ||
|
||
PUSHER_APP_ID= | ||
PUSHER_APP_KEY= | ||
PUSHER_APP_SECRET= | ||
PUSHER_HOST= | ||
PUSHER_PORT=443 | ||
PUSHER_SCHEME=https | ||
PUSHER_APP_CLUSTER=mt1 | ||
|
||
VITE_APP_NAME="${APP_NAME}" | ||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" | ||
VITE_PUSHER_HOST="${PUSHER_HOST}" | ||
VITE_PUSHER_PORT="${PUSHER_PORT}" | ||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" | ||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
/public/storage | ||
/storage/*.key | ||
/vendor | ||
.env | ||
.env.backup | ||
.env.production | ||
.phpunit.result.cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use App\Models\User; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Validation\Rule; | ||
use Laravel\Fortify\Contracts\CreatesNewUsers; | ||
|
||
class CreateNewUser implements CreatesNewUsers | ||
{ | ||
use PasswordValidationRules; | ||
|
||
/** | ||
* Validate and create a newly registered user. | ||
* | ||
* @param array<string, string> $input | ||
*/ | ||
public function create(array $input): User | ||
{ | ||
Validator::make($input, [ | ||
'name' => ['required', 'string', 'max:255'], | ||
'email' => [ | ||
'required', | ||
'string', | ||
'email', | ||
'max:255', | ||
Rule::unique(User::class), | ||
], | ||
'password' => $this->passwordRules(), | ||
])->validate(); | ||
|
||
return User::create([ | ||
'name' => $input['name'], | ||
'email' => $input['email'], | ||
'password' => Hash::make($input['password']), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use Illuminate\Validation\Rules\Password; | ||
|
||
trait PasswordValidationRules | ||
{ | ||
/** | ||
* Get the validation rules used to validate passwords. | ||
* | ||
* @return array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string> | ||
*/ | ||
protected function passwordRules(): array | ||
{ | ||
return ['required', 'string', Password::default(), 'confirmed']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use App\Models\User; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Validator; | ||
use Laravel\Fortify\Contracts\ResetsUserPasswords; | ||
|
||
class ResetUserPassword implements ResetsUserPasswords | ||
{ | ||
use PasswordValidationRules; | ||
|
||
/** | ||
* Validate and reset the user's forgotten password. | ||
* | ||
* @param array<string, string> $input | ||
*/ | ||
public function reset(User $user, array $input): void | ||
{ | ||
Validator::make($input, [ | ||
'password' => $this->passwordRules(), | ||
])->validate(); | ||
|
||
$user->forceFill([ | ||
'password' => Hash::make($input['password']), | ||
])->save(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use App\Models\User; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Validator; | ||
use Laravel\Fortify\Contracts\UpdatesUserPasswords; | ||
|
||
class UpdateUserPassword implements UpdatesUserPasswords | ||
{ | ||
use PasswordValidationRules; | ||
|
||
/** | ||
* Validate and update the user's password. | ||
* | ||
* @param array<string, string> $input | ||
*/ | ||
public function update(User $user, array $input): void | ||
{ | ||
Validator::make($input, [ | ||
'current_password' => ['required', 'string', 'current_password:web'], | ||
'password' => $this->passwordRules(), | ||
], [ | ||
'current_password.current_password' => __('The provided password does not match your current password.'), | ||
])->validateWithBag('updatePassword'); | ||
|
||
$user->forceFill([ | ||
'password' => Hash::make($input['password']), | ||
])->save(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use App\Models\User; | ||
use Illuminate\Contracts\Auth\MustVerifyEmail; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Validation\Rule; | ||
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation; | ||
|
||
class UpdateUserProfileInformation implements UpdatesUserProfileInformation | ||
{ | ||
/** | ||
* Validate and update the given user's profile information. | ||
* | ||
* @param array<string, string> $input | ||
*/ | ||
public function update(User $user, array $input): void | ||
{ | ||
Validator::make($input, [ | ||
'name' => ['required', 'string', 'max:255'], | ||
|
||
'email' => [ | ||
'required', | ||
'string', | ||
'email', | ||
'max:255', | ||
Rule::unique('users')->ignore($user->id), | ||
], | ||
])->validateWithBag('updateProfileInformation'); | ||
|
||
if ($input['email'] !== $user->email && | ||
$user instanceof MustVerifyEmail) { | ||
$this->updateVerifiedUser($user, $input); | ||
} else { | ||
$user->forceFill([ | ||
'name' => $input['name'], | ||
'email' => $input['email'], | ||
])->save(); | ||
} | ||
} | ||
|
||
/** | ||
* Update the given verified user's profile information. | ||
* | ||
* @param array<string, string> $input | ||
*/ | ||
protected function updateVerifiedUser(User $user, array $input): void | ||
{ | ||
$user->forceFill([ | ||
'name' => $input['name'], | ||
'email' => $input['email'], | ||
'email_verified_at' => null, | ||
])->save(); | ||
|
||
$user->sendEmailVerificationNotification(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use App\Actions\Fortify\CreateNewUser; | ||
use App\Actions\Fortify\ResetUserPassword; | ||
use App\Actions\Fortify\UpdateUserPassword; | ||
use App\Actions\Fortify\UpdateUserProfileInformation; | ||
use Illuminate\Cache\RateLimiting\Limit; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\RateLimiter; | ||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Support\Str; | ||
use Laravel\Fortify\Fortify; | ||
|
||
class FortifyServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register any application services. | ||
*/ | ||
public function register(): void | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Bootstrap any application services. | ||
*/ | ||
public function boot(): void | ||
{ | ||
Fortify::createUsersUsing(CreateNewUser::class); | ||
Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class); | ||
Fortify::updateUserPasswordsUsing(UpdateUserPassword::class); | ||
Fortify::resetUserPasswordsUsing(ResetUserPassword::class); | ||
|
||
RateLimiter::for('login', function (Request $request) { | ||
$throttleKey = Str::transliterate(Str::lower($request->input(Fortify::username())).'|'.$request->ip()); | ||
|
||
return Limit::perMinute(5)->by($throttleKey); | ||
}); | ||
|
||
RateLimiter::for('two-factor', function (Request $request) { | ||
return Limit::perMinute(5)->by($request->session()->get('login.id')); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.