-
-
Notifications
You must be signed in to change notification settings - Fork 318
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
Showing
124 changed files
with
7,840 additions
and
7,937 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,25 @@ | ||
<?php | ||
|
||
namespace App\Actions\User; | ||
|
||
use App\Exceptions\InvalidPropertyException; | ||
use App\Exceptions\ModelDBException; | ||
use App\Models\User; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class TokenDisable | ||
{ | ||
/** | ||
* @throws InvalidPropertyException | ||
* @throws ModelDBException | ||
*/ | ||
public function do(): User | ||
{ | ||
/** @var User $user */ | ||
$user = Auth::user(); | ||
$user->token = null; | ||
$user->save(); | ||
|
||
return $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,26 @@ | ||
<?php | ||
|
||
namespace App\Actions\User; | ||
|
||
use App\Exceptions\InvalidPropertyException; | ||
use App\Exceptions\ModelDBException; | ||
use App\Models\User; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class TokenReset | ||
{ | ||
/** | ||
* @throws InvalidPropertyException | ||
* @throws ModelDBException | ||
*/ | ||
public function do(): User | ||
{ | ||
/** @var User $user */ | ||
$user = Auth::user(); | ||
$token = strtr(base64_encode(random_bytes(16)), '+/', '-_'); | ||
$user->token = hash('SHA512', $token); | ||
$user->save(); | ||
|
||
return $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
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,20 @@ | ||
<?php | ||
|
||
namespace App\Contracts\Http; | ||
|
||
/** | ||
* In order to avoid code duplication, we centralize the rule sets | ||
* used during the validation of requests as they are used both | ||
* in Livewire and in the Requests class. | ||
*/ | ||
interface RuleSet | ||
{ | ||
/** | ||
* Return an array containing the rules to be applied to the request attributes. | ||
* | ||
* @return array | ||
*/ | ||
public static function rules(): array; | ||
|
||
// TODO: Associate error message to above rules. | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Enum\Livewire; | ||
|
||
use App\Enum\Traits\WireableEnumTrait; | ||
use Illuminate\Support\Str; | ||
use Livewire\Wireable; | ||
|
||
enum AlbumMode: int implements Wireable | ||
{ | ||
use WireableEnumTrait; | ||
|
||
case FLKR = 0; | ||
case MASONRY = 1; | ||
case SQUARE = 2; | ||
|
||
/** | ||
* get the name as a string instead of the value. | ||
* | ||
* @return string | ||
*/ | ||
public function toCss(): string | ||
{ | ||
return Str::lower($this->name); | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace App\Enum\Livewire; | ||
|
||
use App\Enum\Traits\WireableEnumTrait; | ||
use Livewire\Wireable; | ||
|
||
enum GalleryMode: string implements Wireable | ||
{ | ||
use WireableEnumTrait; | ||
|
||
case ALBUM = 'album'; | ||
case ALBUMS = 'albums'; | ||
case PHOTO = 'photo'; | ||
case MAP = 'map'; | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace App\Enum\Livewire; | ||
|
||
use App\Enum\Traits\WireableEnumTrait; | ||
use Livewire\Wireable; | ||
|
||
enum PageMode: string implements Wireable | ||
{ | ||
use WireableEnumTrait; | ||
|
||
case GALLERY = 'gallery'; | ||
case MAP = 'map'; | ||
case SETTINGS = 'settings'; | ||
case LOGS = 'logs'; | ||
case DIAGNOSTICS = 'diagnostics'; | ||
} |
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,42 @@ | ||
<?php | ||
|
||
namespace App\Enum\Livewire; | ||
|
||
use App\Enum\Traits\WireableEnumTrait; | ||
use Livewire\Wireable; | ||
|
||
enum PhotoOverlayMode: string implements Wireable | ||
{ | ||
use WireableEnumTrait; | ||
|
||
case NONE = 'none'; | ||
case DESC = 'desc'; | ||
case EXIF = 'exif'; | ||
case DATE = 'date'; | ||
|
||
/** | ||
* Iterate to the next OverlayMode. | ||
* | ||
* @return PhotoOverlayMode | ||
*/ | ||
public function next(): PhotoOverlayMode | ||
{ | ||
return match ($this) { | ||
self::NONE => self::DESC, | ||
self::DESC => self::DATE, | ||
self::DATE => self::EXIF, | ||
self::EXIF => self::NONE, | ||
default => self::NONE | ||
}; | ||
} | ||
|
||
/** | ||
* Number of valid values. | ||
* | ||
* @return int | ||
*/ | ||
public static function count(): int | ||
{ | ||
return 4; | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
namespace App\Enum\Traits; | ||
|
||
use App\Exceptions\Internal\LycheeLogicException; | ||
use Closure; | ||
|
||
trait WireableEnumTrait | ||
{ | ||
public function toLivewire(): string|int | ||
{ | ||
return $this->value; | ||
} | ||
|
||
public static function fromLivewire(mixed $value): self | ||
{ | ||
if (!is_string($value) && !is_int($value)) { | ||
throw new LycheeLogicException('Enum could not be instanciated from ' . strval($value), null); | ||
} | ||
|
||
return self::from($value); | ||
} | ||
|
||
/** | ||
* @return string[]|int[]|\Closure | ||
* | ||
* @psalm-return array<string, string|int> | Closure(string):(int|string) | ||
*/ | ||
protected static function values() | ||
{ | ||
return function (string $name): string { | ||
return mb_strtolower($name); | ||
}; | ||
} | ||
} |
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
Oops, something went wrong.