Skip to content

Commit

Permalink
Adding latest updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tnylea committed Apr 17, 2024
1 parent 0d8c12b commit 116398c
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 112 deletions.
3 changes: 3 additions & 0 deletions resources/views/components/devdojoauth/heading.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
<x-auth::devdojoauth.logo class="mx-auto w-auto h-9 text-gray-700 fill-current dark:text-gray-100" />
</x-auth::devdojoauth.link>
<h2 class="mt-2 text-2xl font-medium leading-9 text-center text-gray-800 dark:text-gray-200">{{ $text ?? '' }}</h2>
@if($description ?? false)
<p class="mb-1.5 space-x-0.5 text-sm leading-5 text-center text-gray-500 dark:text-gray-400">{{ $description ?? '' }}</p>
@endif
</div>
3 changes: 2 additions & 1 deletion resources/views/components/devdojoauth/logo.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<svg {{ $attributes }} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 200" fill="none"><path fill="currentColor" fill-rule="evenodd" d="M0 25c29.3 0 46.908-1.117 75-25 28.092 23.883 45.7 25 75 25v96.125c0 32.962-19.709 44.989-55.908 67.08C88.165 191.821 81.796 195.708 75 200c-6.796-4.292-13.165-8.179-19.092-11.795C19.71 166.114 0 154.087 0 121.125V25Zm55 48v6.667h6.667V73c0-7.353 5.983-13.333 13.333-13.333 7.35 0 13.333 5.98 13.333 13.333v6.667H95V73c0-11.043-8.96-20-20-20-11.043 0-20 8.957-20 20Zm-10 60V86.333h60V133H45Z" clip-rule="evenodd"/></svg>
<svg {{ $attributes }} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 200" fill="none"><path fill="currentColor" fill-rule="evenodd" d="M0 25c29.3 0 46.908-1.117 75-25 28.092 23.883 45.7 25 75 25v96.125c0 32.962-19.709 44.989-55.908 67.08C88.165 191.821 81.796 195.708 75 200c-6.796-4.292-13.165-8.179-19.092-11.795C19.71 166.114 0 154.087 0 121.125V25Zm84.837 60.957L75 55.686l-9.837 30.27h-31.83l25.75 18.712-9.837 30.271L75 116.231l25.75 18.708-9.837-30.271 25.754-18.711h-31.83Z" clip-rule="evenodd"/></svg>
{{-- <svg {{ $attributes }} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 200" fill="none"><path fill="currentColor" fill-rule="evenodd" d="M0 25c29.3 0 46.908-1.117 75-25 28.092 23.883 45.7 25 75 25v96.125c0 32.962-19.709 44.989-55.908 67.08C88.165 191.821 81.796 195.708 75 200c-6.796-4.292-13.165-8.179-19.092-11.795C19.71 166.114 0 154.087 0 121.125V25Zm55 48v6.667h6.667V73c0-7.353 5.983-13.333 13.333-13.333 7.35 0 13.333 5.98 13.333 13.333v6.667H95V73c0-11.043-8.96-20-20-20-11.043 0-20 8.957-20 20Zm-10 60V86.333h60V133H45Z" clip-rule="evenodd"/></svg> --}}
37 changes: 24 additions & 13 deletions resources/views/pages/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,37 @@
use App\Models\User;
use Illuminate\Auth\Events\Login;
use function Laravel\Folio\{middleware, name};
use function Livewire\Volt\{state, rules};
use Livewire\Attributes\Validate;
use Livewire\Volt\Component;
middleware(['guest']);
state(['email' => '', 'password' => '', 'remember' => false]);
rules(['email' => 'required|email', 'password' => 'required']);
name('auth.login');
$authenticate = function(){
$this->validate();
new class extends Component
{
#[Validate('required|email')]
public $email = '';
if (!Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) {
$this->addError('email', trans('auth.failed'));
#[Validate('required')]
public $password = '';
return;
}
event(new Login(auth()->guard('web'), User::where('email', $this->email)->first(), $this->remember));
public $remember = false;
public function authenticate()
{
$this->validate();
if (!Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) {
$this->addError('email', trans('auth.failed'));
return redirect()->intended('/');
}
return;
}
event(new Login(auth()->guard('web'), User::where('email', $this->email)->first(), $this->remember));
return redirect()->intended('/');
}
};
?>

Expand Down
105 changes: 57 additions & 48 deletions resources/views/pages/auth/password/[token].blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,79 @@
use Illuminate\Auth\Events\PasswordReset;
use function Laravel\Folio\name;
use function Livewire\Volt\{state, rules, mount};
state(['token', 'email', 'password', 'passwordConfirmation']);
rules(['token' => 'required', 'email' => 'required|email', 'password' => 'required|min:8|same:passwordConfirmation']);
name('auth.password.reset');
use Livewire\Volt\Component;
use Livewire\Attributes\Validate;
mount(function ($token){
$this->email = request()->query('email', '');
$this->token = $token;
});
name('password.reset');
$resetPassword = function(){
$this->validate();
new class extends Component
{
#[Validate('required')]
public $token;
$response = Password::broker()->reset(
[
'token' => $this->token,
'email' => $this->email,
'password' => $this->password
],
function ($user, $password) {
$user->password = Hash::make($password);
#[Validate('required|email')]
public $email;
$user->setRememberToken(Str::random(60));
#[Validate('required|min:8|same:passwordConfirmation')]
public $password;
public $passwordConfirmation;
$user->save();
public function mount($token)
{
$this->email = request()->query('email', '');
$this->token = $token;
}
event(new PasswordReset($user));
public function resetPassword()
{
$this->validate();
Auth::guard()->login($user);
}
);
$response = Password::broker()->reset(
[
'token' => $this->token,
'email' => $this->email,
'password' => $this->password,
],
function ($user, $password) {
$user->password = Hash::make($password);
if ($response == Password::PASSWORD_RESET) {
session()->flash(trans($response));
$user->setRememberToken(Str::random(60));
return redirect('/');
}
$user->save();
event(new PasswordReset($user));
Auth::guard()->login($user);
},
);
$this->addError('email', trans($response));
}
if ($response == Password::PASSWORD_RESET) {
session()->flash(trans($response));
return redirect('/');
}
$this->addError('email', trans($response));
}
};
?>

<x-auth::layouts.app>
<div class="flex flex-col justify-center items-stretch py-10 w-screen min-h-screen sm:items-center">

<div class="sm:mx-auto sm:w-full sm:max-w-md">
<x-auth::devdojoauth.link href="/">
<x-auth::devdojoauth.logo class="mx-auto w-auto h-10 text-gray-700 fill-current dark:text-gray-100" />
</x-auth::devdojoauth.link>
<h2 class="mt-5 text-2xl font-extrabold leading-9 text-center text-gray-800 dark:text-gray-200">Reset password</h2>
</div>
<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
<div class="px-10 py-0 sm:py-8 sm:shadow-sm sm:bg-white dark:sm:bg-gray-950/50 dark:border-gray-200/10 sm:border sm:rounded-lg border-gray-200/60">
@volt('auth.password.token')
<form wire:submit="resetPassword" class="space-y-6">
<x-auth::devdojoauth.input label="Email address" type="email" id="email" name="email" wire:model="email" />
<x-auth::devdojoauth.input label="Password" type="password" id="password" name="password" wire:model="password" />
<x-auth::devdojoauth.input label="Confirm Password" type="password" id="password_confirmation" name="password_confirmation" wire:model="passwordConfirmation" />
<x-auth::devdojoauth.button type="primary" rounded="md" submit="true">Reset password</x-auth::devdojoauth.button>
</form>
@endvolt
</div>
</div>
<x-auth::devdojoauth.heading text="Reset password" />

<x-auth::devdojoauth.container>
@volt('auth.password.token')
<form wire:submit="resetPassword" class="space-y-6">
<x-auth::devdojoauth.input label="Email address" type="email" id="email" name="email" wire:model="email" />
<x-auth::devdojoauth.input label="Password" type="password" id="password" name="password" wire:model="password" />
<x-auth::devdojoauth.input label="Confirm Password" type="password" id="password_confirmation" name="password_confirmation" wire:model="passwordConfirmation" />
<x-auth::devdojoauth.button type="primary" rounded="md" submit="true">Reset password</x-auth::devdojoauth.button>
</form>
@endvolt
</x-auth::devdojoauth.container>
</div>
</x-auth::layouts.app>
32 changes: 19 additions & 13 deletions resources/views/pages/auth/password/confirm.blade.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
<?php
use function Laravel\Folio\name;
use function Livewire\Volt\{state, rules};
use function Laravel\Folio\name;
use Livewire\Volt\Component;
use Livewire\Attributes\Validate;
state(['password' => '']);
rules(['password' => 'required|current_password']);
name('auth.password.confirm');
name('password.confirm');
$confirm = function(){
new class extends Component
{
#[Validate('required|current_password')]
public $password = '';
public function confirm()
{
$this->validate();
session()->put('auth.password_confirmed_at', time());
return redirect()->intended('/');
};
}
};
?>

<x-auth::layouts.app>
<div class="flex flex-col justify-center items-stretch py-10 w-screen min-h-screen sm:items-center">

<div class="sm:mx-auto sm:w-full sm:max-w-md">
<x-auth::devdojoauth.heading text="Reset password" description="Please confirm your password before continuing" />
{{-- <div class="sm:mx-auto sm:w-full sm:max-w-md">
<x-auth::devdojoauth.link href="/">
<x-auth::devdojoauth.logo class="mx-auto w-auto h-10 text-gray-700 fill-current dark:text-gray-100" />
</x-auth::devdojoauth.link>
Expand All @@ -30,10 +38,9 @@
<p class="space-x-0.5 text-sm leading-5 text-center text-gray-600 dark:text-gray-400">
Please confirm your password before continuing
</p>
</div>
</div> --}}

<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
<div class="px-10 py-0 sm:py-8 sm:shadow-sm sm:bg-white dark:sm:bg-gray-950/50 dark:border-gray-200/10 sm:border sm:rounded-lg border-gray-200/60">
<x-auth::devdojoauth.container>
@volt('auth.password.confirm')
<form wire:submit="confirm" class="space-y-6">
<x-auth::devdojoauth.input label="Password" type="password" id="password" name="password" wire:model="password" />
Expand All @@ -43,8 +50,7 @@
<x-auth::devdojoauth.button type="primary" rounded="md" submit="true">Confirm password</x-auth::devdojoauth.button>
</form>
@endvolt
</div>
</div>
</x-auth::devdojoauth.container>
</div>

</x-auth::layouts.app>
30 changes: 18 additions & 12 deletions resources/views/pages/auth/password/reset.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@
use Illuminate\Support\Facades\Password;
use function Laravel\Folio\name;
use function Livewire\Volt\{state, rules};
use Livewire\Volt\Component;
use Livewire\Attributes\Validate;
state(['email' => null, 'emailSentMessage' => false]);
rules(['email' => 'required|email']);
name('auth.password.request');
new class extends Component
{
#[Validate('required|email')]
public $email = null;
public $emailSentMessage = false;
$sendResetPasswordLink = function(){
$this->validate();
public function sendResetPasswordLink()
{
$this->validate();
$response = Password::broker()->sendResetLink(['email' => $this->email]);
$response = Password::broker()->sendResetLink(['email' => $this->email]);
if ($response == Password::RESET_LINK_SENT) {
$this->emailSentMessage = trans($response);
if ($response == Password::RESET_LINK_SENT) {
$this->emailSentMessage = trans($response);
return;
}
return;
}
$this->addError('email', trans($response));
}
$this->addError('email', trans($response));
}
};
?>

Expand Down
44 changes: 29 additions & 15 deletions resources/views/pages/auth/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,44 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Auth\Events\Registered;
use Livewire\Volt\Component;
use Livewire\Attributes\Validate;
use function Laravel\Folio\{middleware, name};
use function Livewire\Volt\{state, rules};
middleware(['guest']);
state(['name' => '', 'email' => '', 'password' => '', 'passwordConfirmation' => '']);
rules(['name' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required|min:8|same:passwordConfirmation']);
name('auth.register');
$register = function(){
$this->validate();
new class extends Component
{
#[Validate('required')]
public $name = '';
#[Validate('required|email|unique:users')]
public $email = '';
#[Validate('required|min:8|same:passwordConfirmation')]
public $password = '';
#[Validate('required|min:8|same:password')]
public $passwordConfirmation = '';
public function register()
{
$this->validate();
$user = User::create([
'email' => $this->email,
'name' => $this->name,
'password' => Hash::make($this->password),
]);
$user = User::create([
'email' => $this->email,
'name' => $this->name,
'password' => Hash::make($this->password),
]);
event(new Registered($user));
event(new Registered($user));
Auth::login($user, true);
Auth::login($user, true);
return redirect()->intended('/');
}
return redirect()->intended('/');
}
};
?>

Expand Down
Loading

0 comments on commit 116398c

Please sign in to comment.