diff --git a/app/Livewire/Auth/Login.php b/app/Livewire/Auth/Login.php new file mode 100644 index 0000000..d3b638e --- /dev/null +++ b/app/Livewire/Auth/Login.php @@ -0,0 +1,55 @@ + 'Masuk Akun', +])] +class Login extends Component +{ + #[Validate(['required', 'string'], attribute: 'nama pengguna atau alamat surel')] + public string $login = ''; + + #[Validate('required', attribute: 'kata sandi')] + public string $password = ''; + + public function auth() + { + $this->validate(); + + $identifier = filter_var($this->login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; + + if (! auth()->attempt( + [$identifier => $this->login, 'password' => $this->password], + )) { + $this->redirectRoute('login', navigate: true); + + return; + } + + if (auth()->user()->status !== UserStatus::ACTIVE) { + auth()->logout(); + + $this->redirectRoute('login', navigate: true); + } + + session()->regenerate(); + + $this->redirectIntended('/studio/dashboard/overview', navigate: true); + } + + public function updated(string $prop, string $value) + { + $this->validateOnly($prop); + } + + public function render() + { + return view('livewire.auth.login'); + } +} diff --git a/resources/views/components/layouts/auth.blade.php b/resources/views/components/layouts/auth.blade.php new file mode 100644 index 0000000..8443082 --- /dev/null +++ b/resources/views/components/layouts/auth.blade.php @@ -0,0 +1,19 @@ + + + +
+ + +