Skip to content

Commit

Permalink
feat: implement laravel jetstream and fortify (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed May 30, 2021
1 parent 880b9ee commit 6874b1e
Show file tree
Hide file tree
Showing 64 changed files with 3,212 additions and 947 deletions.
5 changes: 3 additions & 2 deletions app/Helpers/LocaleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LocaleHelper
public static function getLocale()
{
$locale = Auth::check() ? Auth::user()->locale : null;
if (!$locale) {
if (! $locale) {
$locale = LanguageDetector::detect() ?: config('app.locale');
}

Expand All @@ -28,7 +28,8 @@ public static function getLocale()
/**
* Get the current lang from locale.
*
* @return string lang, lowercase form.
* @param mixed|null $locale
* @return string lang, lowercase form
*/
public static function getLang($locale = null)
{
Expand Down
30 changes: 0 additions & 30 deletions app/Http/Controllers/Auth/ForgotPasswordController.php

This file was deleted.

66 changes: 0 additions & 66 deletions app/Http/Controllers/Auth/LoginController.php

This file was deleted.

66 changes: 0 additions & 66 deletions app/Http/Controllers/Auth/RegisterController.php

This file was deleted.

37 changes: 0 additions & 37 deletions app/Http/Controllers/Auth/ResetPasswordController.php

This file was deleted.

70 changes: 0 additions & 70 deletions app/Http/Controllers/Auth/VerificationController.php

This file was deleted.

3 changes: 2 additions & 1 deletion app/Models/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Spatie\Activitylog\Traits\LogsActivity;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable, LogsActivity, HasFactory, HasApiTokens;
use Notifiable, LogsActivity, HasFactory, HasApiTokens, TwoFactorAuthenticatable;

/**
* The attributes that are mass assignable.
Expand Down
43 changes: 43 additions & 0 deletions app/Providers/FortifyServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\Providers;

use Illuminate\Http\Request;
use Laravel\Fortify\Fortify;
use App\Services\User\CreateAccount;
use Illuminate\Support\ServiceProvider;
use App\Services\User\ResetUserPassword;
use Illuminate\Cache\RateLimiting\Limit;
use App\Services\User\UpdateUserPassword;
use Illuminate\Support\Facades\RateLimiter;
use App\Services\User\UpdateUserProfileInformation;

class FortifyServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register()
{
//
}

/**
* Bootstrap any application services.
*/
public function boot()
{
Fortify::createUsersUsing(CreateAccount::class);
Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
Fortify::resetUserPasswordsUsing(ResetUserPassword::class);

RateLimiter::for('login', function (Request $request) {
return Limit::perMinute(5)->by($request->email.$request->ip());
});

RateLimiter::for('two-factor', function (Request $request) {
return Limit::perMinute(5)->by($request->session()->get('login.id'));
});
}
}

0 comments on commit 6874b1e

Please sign in to comment.