-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eef2748
commit d03d807
Showing
14 changed files
with
144 additions
and
128 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
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,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ARKEcosystem\Foundation\Blog\Components\Concerns; | ||
|
||
use Illuminate\Contracts\Auth\Authenticatable; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
/** | ||
* @property ?Authenticatable $user | ||
*/ | ||
trait InteractsWithUser | ||
{ | ||
public function getUserProperty(): ?Authenticatable | ||
{ | ||
return Auth::user(); | ||
} | ||
} |
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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ARKEcosystem\Foundation\Blog\Contracts; | ||
|
||
interface UserRole | ||
{ | ||
public static function toArray(): array; | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Blog/Http/Middleware/EnforceTwoFactorAuthentication.php
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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ARKEcosystem\Foundation\Blog\Http\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
|
||
final class EnforceTwoFactorAuthentication | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param Request $request | ||
* @return mixed | ||
*/ | ||
public function handle($request, Closure $next) | ||
{ | ||
$user = $request->user(); | ||
|
||
if (config('web.2fa_enabled') === false) { | ||
return $next($request); | ||
} | ||
|
||
if ($user === null) { | ||
return $next($request); | ||
} | ||
|
||
if ($user->two_factor_secret) { | ||
return $next($request); | ||
} | ||
|
||
return redirect()->route('kiosk'); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ARKEcosystem\Foundation\Blog\Models\Concerns; | ||
|
||
use Carbon\Carbon; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Config; | ||
|
||
trait HasLocalizedTimestamps | ||
{ | ||
public function getCreatedAtLocalAttribute(): Carbon | ||
{ | ||
$timezone = Auth::check() ? Auth::user()->timezone : Config::get('app.timezone'); | ||
|
||
return Carbon::parse($this->created_at)->timezone($timezone); | ||
} | ||
|
||
public function getUpdatedAtLocalAttribute(): Carbon | ||
{ | ||
$timezone = Auth::check() ? Auth::user()->timezone : Config::get('app.timezone'); | ||
|
||
return Carbon::parse($this->updated_at)->timezone($timezone); | ||
} | ||
} |
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
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
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
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
'CommonMark', | ||
'DataBags', | ||
'Documentation', | ||
'Fortify', | ||
'NumberFormatter', | ||
'Rules', | ||
'Support', | ||
|
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
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