-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from deanblackborough/v1.08.0
v1.08.0
- Loading branch information
Showing
22 changed files
with
381 additions
and
276 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,45 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace App\Actions\Account; | ||
|
||
use App\Actions\Action; | ||
use App\Api\Service; | ||
|
||
/** | ||
* @author Dean Blackborough <dean@g3d-development.com> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class CreateNewPassword extends Action | ||
{ | ||
public function __invoke( | ||
Service $api, | ||
array $input | ||
): int | ||
{ | ||
$post_response = $api->createNewPassword($input); | ||
|
||
if ($post_response['status'] === 204) { | ||
return 204; | ||
} | ||
|
||
if ($post_response['status'] === 422) { | ||
$this->validation_errors = $post_response['fields']; | ||
$this->parameters = [ | ||
'encrypted_token' => $input['encrypted_token'], | ||
'email' => $input['email'], | ||
]; | ||
|
||
return 422; | ||
} | ||
|
||
$this->message = $post_response['content']; | ||
$this->parameters = [ | ||
'encrypted_token' => $input['encrypted_token'], | ||
'email' => $input['email'], | ||
]; | ||
|
||
return $post_response['status']; | ||
} | ||
} |
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,56 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace App\Actions\Account; | ||
|
||
use App\Actions\Action; | ||
use App\Api\Service; | ||
use App\Models\PartialRegistration; | ||
use App\Notifications\Registered; | ||
use Illuminate\Support\Facades\Notification; | ||
|
||
/** | ||
* @author Dean Blackborough <dean@g3d-development.com> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class CreatePassword extends Action | ||
{ | ||
public function __invoke( | ||
Service $api, | ||
array $input | ||
): int | ||
{ | ||
$post_response = $api->createPassword($input); | ||
|
||
if ($post_response['status'] === 204) { | ||
|
||
Notification::route('mail', $input['email']) | ||
->notify(new Registered()); | ||
|
||
PartialRegistration::query() | ||
->where('token', '=', $input['token']) | ||
->delete(); | ||
|
||
return 204; | ||
} | ||
|
||
if ($post_response['status'] === 422) { | ||
$this->validation_errors = $post_response['fields']; | ||
$this->parameters = [ | ||
'token' => $input['token'], | ||
'email' => $input['email'], | ||
]; | ||
|
||
return 422; | ||
} | ||
|
||
$this->message = $post_response['content']; | ||
$this->parameters = [ | ||
'token' => $input['token'], | ||
'email' => $input['email'], | ||
]; | ||
|
||
return $post_response['status']; | ||
} | ||
} |
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,48 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace App\Actions\Account; | ||
|
||
use App\Actions\Action; | ||
use App\Api\Service; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Notification; | ||
|
||
/** | ||
* @author Dean Blackborough <dean@g3d-development.com> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class ForgotPassword extends Action | ||
{ | ||
public function __invoke( | ||
Service $api, | ||
array $input | ||
): int | ||
{ | ||
$post_response = $api->forgotPassword($input); | ||
|
||
if ($post_response['status'] === 201) { | ||
|
||
$this->parameters = $post_response['content']['uris']['create-new-password']['parameters']; | ||
|
||
Notification::route('mail', $input['email']) | ||
->notify(new \App\Notifications\ForgotPassword($input['email'], $this->parameters['encrypted_token'])); | ||
|
||
return 201; | ||
} | ||
|
||
if ($post_response['status'] === 422) { | ||
$this->validation_errors = $post_response['fields']; | ||
|
||
return 422; | ||
} | ||
|
||
$this->message = $post_response['content']; | ||
$this->parameters = [ | ||
'email' => $input['email'], | ||
]; | ||
|
||
return $post_response['status']; | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace App\Actions\Account; | ||
|
||
use App\Actions\Action; | ||
use App\Api\Service; | ||
use App\Models\PartialRegistration; | ||
use App\Notifications\CreatePassword; | ||
use Illuminate\Support\Facades\Notification; | ||
|
||
/** | ||
* @author Dean Blackborough <dean@g3d-development.com> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Register extends Action | ||
{ | ||
public function __invoke( | ||
Service $api, | ||
array $input | ||
): int | ||
{ | ||
$post_response = $api->register($input); | ||
|
||
if ($post_response['status'] === 201) { | ||
|
||
$this->parameters = $post_response['content']['uris']['create-password']['parameters']; | ||
|
||
$model = new PartialRegistration(); | ||
$model->token = $this->parameters['token']; | ||
$model->email = $this->parameters['email']; | ||
$model->save(); | ||
|
||
Notification::route('mail', $input['email']) | ||
->notify((new CreatePassword($input['email'], $this->parameters['token']))->delay(now()->addMinute())); | ||
|
||
return 201; | ||
} | ||
|
||
if ($post_response['status'] === 422) { | ||
$this->validation_errors = $post_response['fields']; | ||
|
||
return 422; | ||
} | ||
|
||
$this->message = $post_response['content']; | ||
|
||
return $post_response['status']; | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace App\Actions\Account; | ||
|
||
use App\Actions\Action; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
/** | ||
* @author Dean Blackborough <dean@g3d-development.com> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class SignIn extends Action | ||
{ | ||
public function __invoke( | ||
array $input | ||
): int | ||
{ | ||
if (array_key_exists('email', $input) === false || $input['email'] === null) { | ||
$this->validation_errors['email']['errors'] = [ | ||
'You need to provide your email address' | ||
]; | ||
} | ||
if (array_key_exists('password', $input) === false || $input['password'] === null) { | ||
$this->validation_errors['password']['errors'] = [ | ||
'You need to provide your password' | ||
]; | ||
} | ||
|
||
if ($this->validation_errors !== []) { | ||
return 422; | ||
} | ||
|
||
|
||
if (Auth::attempt($input, array_key_exists('remember_me', $input))) { | ||
return 204; | ||
} | ||
|
||
$this->validation_errors = Auth::errors(); | ||
|
||
return 422; | ||
} | ||
} |
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
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.