From b9c982bd0884938c7d96ab01ef9eeb37494512fa Mon Sep 17 00:00:00 2001 From: Tony Air Date: Fri, 7 Jan 2022 20:33:51 +0200 Subject: [PATCH] IMPR: add change password URL. Ref: https://web.dev/change-password-url/ --- _config/config.yml | 1 + src/Controllers/ManifestController.php | 3 +-- src/Controllers/WellKnownController.php | 35 +++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/Controllers/WellKnownController.php diff --git a/_config/config.yml b/_config/config.yml index 0ca92e2..3981d13 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -6,6 +6,7 @@ SilverStripe\Control\Director: rules: 'manifest.json': 'A2nt\ProgressiveWebApp\Controllers\ManifestController' 'sw.js/$Action': 'A2nt\ProgressiveWebApp\Controllers\ServiceWorkerController' + '.well-known/$Action!': 'A2nt\ProgressiveWebApp\Controllers\WellKnownController' SilverStripe\CMS\Model\SiteTree: extensions: diff --git a/src/Controllers/ManifestController.php b/src/Controllers/ManifestController.php index e5b2d9c..b9ea261 100644 --- a/src/Controllers/ManifestController.php +++ b/src/Controllers/ManifestController.php @@ -16,9 +16,8 @@ class ManifestController extends Controller * @var array */ private static $allowed_actions = [ - 'index' + 'index', ]; - /** * Default controller action for the manifest.json file * diff --git a/src/Controllers/WellKnownController.php b/src/Controllers/WellKnownController.php new file mode 100644 index 0000000..28c300d --- /dev/null +++ b/src/Controllers/WellKnownController.php @@ -0,0 +1,35 @@ +getRequest(); + $action = $req->param('Action'); + switch($action) { + case 'change-password': + return $this->changepassword(); + default: + return $this->httpError(404, 'Not found'); + } + } + + public function changepassword() + { + return $this->redirect( + Director::absoluteURL( + Security::singleton()->Link('changepassword') + ), 303 + ); + } +}