Skip to content

Commit

Permalink
Merge pull request #152 from andrewdwallo/development-4.x
Browse files Browse the repository at this point in the history
Development 4.x
  • Loading branch information
andrewdwallo authored Jul 28, 2024
2 parents 1436e28 + 0a12fb4 commit 0776c78
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions lang/en/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
'email_not_found' => 'We were unable to find a registered user with this email address.',
'employee_already_belongs_to_company' => 'This employee already belongs to the company.',
'employee_already_invited' => 'This employee has already been invited to the company.',
'generic_error' => 'An error occurred while processing your request.',
'invalid_password' => 'The password you entered is invalid.',
'no_email_with_account' => 'No email address is associated with this :Provider account. Please try a different account.',
'password_does_not_match' => 'The provided password does not match your current password.',
Expand Down
2 changes: 1 addition & 1 deletion resources/views/profile/connected-accounts-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</x-filament::button>
@endif

@if ($this->user->password !== null || $this->accounts->count() > 1)
@if ($this->user?->password !== null || $this->accounts->count() > 1)
<x-filament::button color="danger" size="sm"
wire:click="confirmRemove('{{ $account->id }}')">
{{ __('filament-companies::default.buttons.remove') }}
Expand Down
4 changes: 4 additions & 0 deletions src/Http/Controllers/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ protected function handleError(Request $request): RedirectResponse
{
$error_description = $request->input('error_description');

if ($error_description === null) {
$error_description = __('filament-companies::default.errors.generic_error');
}

$targetUrl = $this->guard->check() ? filament()->getHomeUrl() : null;

if ($targetUrl === null) {
Expand Down
14 changes: 10 additions & 4 deletions src/Http/Livewire/ConnectedAccountsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ public function confirmRemove(string | int $accountId): void
*/
public function setAvatarAsProfilePhoto(string | int $accountId): RedirectResponse | Redirector
{
$account = Auth::user()->connectedAccounts
->where('user_id', ($user = Auth::user())->getAuthIdentifier())
$user = $this->user;

$account = $this->user?->connectedAccounts
->where('user_id', $user?->getAuthIdentifier())
->where('id', $accountId)
->first();

Expand All @@ -74,7 +76,7 @@ public function setAvatarAsProfilePhoto(string | int $accountId): RedirectRespon
public function removeConnectedAccount(string | int $accountId): void
{
DB::table('connected_accounts')
->where('user_id', Auth::user()?->getAuthIdentifier())
->where('user_id', $this->user?->getAuthIdentifier())
->where('id', $accountId)
->delete();

Expand All @@ -96,7 +98,11 @@ public function cancelConnectedAccountRemoval(): void
*/
public function getAccountsProperty(): Collection
{
return Auth::user()->connectedAccounts
if ($this->user?->connectedAccounts === null) {
return collect();
}

return $this->user->connectedAccounts
->map(static function (ConnectedAccount $account) {
return (object) $account->getSharedData();
});
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Livewire/CreateCompanyForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function createCompany(CreatesCompanies $creator): Response | Redirector
{
$this->resetErrorBag();

$creator->create(Auth::user(), $this->state);
$creator->create($this->user, $this->state);

$name = $this->state['name'];

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Livewire/SetPasswordForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setPassword(SetsUserPasswords $setter): void
{
$this->resetErrorBag();

$setter->set(Auth::user(), $this->state);
$setter->set($this->user, $this->state);

$this->state = [
'password' => '',
Expand All @@ -39,7 +39,7 @@ public function setPassword(SetsUserPasswords $setter): void

if (FilamentCompanies::hasNotificationsFeature()) {
if (method_exists($setter, 'passwordSet')) {
$setter->passwordSet(Auth::user(), $this->state);
$setter->passwordSet($this->user, $this->state);
} else {
$this->passwordSet();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Http/Livewire/UpdatePasswordForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function updatePassword(UpdatesUserPasswords $updater): void
{
$this->resetErrorBag();

$updater->update(Auth::user(), $this->state);
$updater->update($this->user, $this->state);

if (session() !== null) {
session()->put([
'password_hash_' . Auth::getDefaultDriver() => Auth::user()?->getAuthPassword(),
'password_hash_' . Auth::getDefaultDriver() => $this->user?->getAuthPassword(),
]);
}

Expand All @@ -46,7 +46,7 @@ public function updatePassword(UpdatesUserPasswords $updater): void

if (FilamentCompanies::hasNotificationsFeature()) {
if (method_exists($updater, 'passwordUpdated')) {
$updater->passwordUpdated(Auth::user(), $this->state);
$updater->passwordUpdated($this->user, $this->state);
} else {
$this->passwordUpdated();
}
Expand Down
10 changes: 5 additions & 5 deletions src/Http/Livewire/UpdateProfileInformationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class UpdateProfileInformationForm extends Component
*/
public function mount(): void
{
$user = Auth::user();
$user = $this->user;

$this->state = ['email' => $user?->email, ...$user?->withoutRelations()->toArray()];
}
Expand All @@ -49,7 +49,7 @@ public function updateProfileInformation(UpdatesUserProfileInformation $updater)
$this->resetErrorBag();

$updater->update(
Auth::user(),
$this->user,
$this->photo
? [...$this->state, 'photo' => $this->photo]
: $this->state
Expand All @@ -61,7 +61,7 @@ public function updateProfileInformation(UpdatesUserProfileInformation $updater)

if (FilamentCompanies::hasNotificationsFeature()) {
if (method_exists($updater, 'profileInformationUpdated')) {
$updater->profileInformationUpdated(Auth::user(), $this->state);
$updater->profileInformationUpdated($this->user, $this->state);
} else {
$this->profileInformationUpdated();
}
Expand All @@ -82,15 +82,15 @@ protected function profileInformationUpdated(): void
*/
public function deleteProfilePhoto(): void
{
Auth::user()?->deleteProfilePhoto();
$this->user?->deleteProfilePhoto();
}

/**
* Sent the email verification.
*/
public function sendEmailVerification(): void
{
Auth::user()?->sendEmailVerificationNotification();
$this->user?->sendEmailVerificationNotification();

$this->verificationLinkSent = true;

Expand Down

0 comments on commit 0776c78

Please sign in to comment.