chore(login & register): menghapus return type
This commit is contained in:
parent
6fb2832ad5
commit
cf2c90b8d0
@ -21,7 +21,7 @@ class Login extends Component
|
|||||||
#[Validate('required', attribute: 'kata sandi')]
|
#[Validate('required', attribute: 'kata sandi')]
|
||||||
public string $password = '';
|
public string $password = '';
|
||||||
|
|
||||||
public function mount(): void
|
public function mount()
|
||||||
{
|
{
|
||||||
if (! request()->has('message')) {
|
if (! request()->has('message')) {
|
||||||
return;
|
return;
|
||||||
@ -36,7 +36,7 @@ public function mount(): void
|
|||||||
JS);
|
JS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): void
|
public function auth()
|
||||||
{
|
{
|
||||||
$this->validate();
|
$this->validate();
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public function auth(): void
|
|||||||
$this->redirectByRole($user->roles->pluck('name')->toArray());
|
$this->redirectByRole($user->roles->pluck('name')->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function attemptLogin(): bool
|
protected function attemptLogin()
|
||||||
{
|
{
|
||||||
$field = filter_var($this->login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
|
$field = filter_var($this->login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
|
||||||
|
|
||||||
@ -77,12 +77,12 @@ protected function attemptLogin(): bool
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function userIsActive($user): bool
|
protected function userIsActive($user)
|
||||||
{
|
{
|
||||||
return $user?->status === UserStatus::ACTIVE;
|
return $user?->status === UserStatus::ACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function redirectByRole(array $roles): void
|
protected function redirectByRole(array $roles)
|
||||||
{
|
{
|
||||||
if (array_intersect($roles, ['Developer', 'Owner', 'Leader', 'Admin'])) {
|
if (array_intersect($roles, ['Developer', 'Owner', 'Leader', 'Admin'])) {
|
||||||
$this->redirectIntended('/studio/dashboard/overview', navigate: true);
|
$this->redirectIntended('/studio/dashboard/overview', navigate: true);
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Traits\WithToast;
|
use App\Traits\WithToast;
|
||||||
use App\Traits\WithUpdatedData;
|
use App\Traits\WithUpdatedData;
|
||||||
use Illuminate\Contracts\View\View;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Livewire\Attributes\Layout;
|
use Livewire\Attributes\Layout;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
@ -36,7 +35,7 @@ public function mount()
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateStep(int $value): void
|
public function updateStep(int $value)
|
||||||
{
|
{
|
||||||
if ($this->shouldValidateBeforeChangingStep()) {
|
if ($this->shouldValidateBeforeChangingStep()) {
|
||||||
$this->form->validateStep1();
|
$this->form->validateStep1();
|
||||||
@ -45,7 +44,7 @@ public function updateStep(int $value): void
|
|||||||
$this->currentStep = $value;
|
$this->currentStep = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function nextStep(): void
|
public function nextStep()
|
||||||
{
|
{
|
||||||
match ($this->currentStep) {
|
match ($this->currentStep) {
|
||||||
1 => $this->form->validateStep1(),
|
1 => $this->form->validateStep1(),
|
||||||
@ -58,19 +57,19 @@ public function nextStep(): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prevStep(): void
|
public function prevStep()
|
||||||
{
|
{
|
||||||
if ($this->currentStep > 1) {
|
if ($this->currentStep > 1) {
|
||||||
$this->currentStep--;
|
$this->currentStep--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updated(string $propertyName, $value): void
|
public function updated(string $propertyName, $value)
|
||||||
{
|
{
|
||||||
$this->validateUpdatedField($propertyName);
|
$this->validateUpdatedField($propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register(): void
|
public function register()
|
||||||
{
|
{
|
||||||
$this->form->auth();
|
$this->form->auth();
|
||||||
|
|
||||||
@ -79,7 +78,7 @@ public function register(): void
|
|||||||
$this->redirectAfterRegistration();
|
$this->redirectAfterRegistration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(): View
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.auth.register');
|
return view('livewire.auth.register');
|
||||||
}
|
}
|
||||||
@ -87,7 +86,7 @@ public function render(): View
|
|||||||
/**
|
/**
|
||||||
* Determine whether validation is required before changing step.
|
* Determine whether validation is required before changing step.
|
||||||
*/
|
*/
|
||||||
protected function shouldValidateBeforeChangingStep(): bool
|
protected function shouldValidateBeforeChangingStep()
|
||||||
{
|
{
|
||||||
return $this->currentStep === 1;
|
return $this->currentStep === 1;
|
||||||
}
|
}
|
||||||
@ -95,7 +94,7 @@ protected function shouldValidateBeforeChangingStep(): bool
|
|||||||
/**
|
/**
|
||||||
* Validate updated field based on current form step rules.
|
* Validate updated field based on current form step rules.
|
||||||
*/
|
*/
|
||||||
protected function validateUpdatedField(string $propertyName): void
|
protected function validateUpdatedField(string $propertyName)
|
||||||
{
|
{
|
||||||
$field = Str::replace('form.', '', $propertyName);
|
$field = Str::replace('form.', '', $propertyName);
|
||||||
|
|
||||||
@ -111,7 +110,7 @@ protected function validateUpdatedField(string $propertyName): void
|
|||||||
/**
|
/**
|
||||||
* Show success toast after registration.
|
* Show success toast after registration.
|
||||||
*/
|
*/
|
||||||
protected function sendRegistrationSuccessToast(): void
|
protected function sendRegistrationSuccessToast()
|
||||||
{
|
{
|
||||||
$this->toast('Selamat, akun Anda berhasil didaftarkan. Silakan periksa email Anda untuk melakukan verifikasi.');
|
$this->toast('Selamat, akun Anda berhasil didaftarkan. Silakan periksa email Anda untuk melakukan verifikasi.');
|
||||||
}
|
}
|
||||||
@ -119,7 +118,7 @@ protected function sendRegistrationSuccessToast(): void
|
|||||||
/**
|
/**
|
||||||
* Dispatch notification to privileged users when a new member registers.
|
* Dispatch notification to privileged users when a new member registers.
|
||||||
*/
|
*/
|
||||||
protected function notifyPrivilegedUsersAboutNewMember(): void
|
protected function notifyPrivilegedUsersAboutNewMember()
|
||||||
{
|
{
|
||||||
$userIds = User::role(['Developer', 'Owner'])->pluck('id')->toArray();
|
$userIds = User::role(['Developer', 'Owner'])->pluck('id')->toArray();
|
||||||
|
|
||||||
@ -136,7 +135,7 @@ protected function notifyPrivilegedUsersAboutNewMember(): void
|
|||||||
/**
|
/**
|
||||||
* Redirect user after successful registration.
|
* Redirect user after successful registration.
|
||||||
*/
|
*/
|
||||||
protected function redirectAfterRegistration(): void
|
protected function redirectAfterRegistration()
|
||||||
{
|
{
|
||||||
$this->redirectIntended('/member/overview', navigate: true);
|
$this->redirectIntended('/member/overview', navigate: true);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user