diff --git a/app/src/Controller/AppController.php b/app/src/Controller/AppController.php index 4eb2bedec..0e02ae767 100644 --- a/app/src/Controller/AppController.php +++ b/app/src/Controller/AppController.php @@ -109,7 +109,8 @@ public function beforeRender(\Cake\Event\Event $event) { parent::beforeRender($event); // The current user, if authenticated - $this->set('vv_user', $this->request->getSession()->read('Auth.User')); + $curUser = $this->request->getSession()->read('Auth.User'); + $this->set('vv_user', $curUser); // The current Matchgrid, as determined in beforeFilter() $mgid = null; @@ -123,7 +124,7 @@ public function beforeRender(\Cake\Event\Event $event) { $this->set('vv_matchgrids', $this->Matchgrids->find('list')->find('activeMatchGrids')->toArray()); // The set of menu permissions, so the layout knows what to render - if($this->Authorization) { + if($this->Authorization && $curUser) { // Ordinarily $this->Authorization will be set, but under certain error conditions // it won't, which will prevent error messages from rendering diff --git a/app/src/Controller/MatchgridsController.php b/app/src/Controller/MatchgridsController.php index f377c6041..c686734cb 100644 --- a/app/src/Controller/MatchgridsController.php +++ b/app/src/Controller/MatchgridsController.php @@ -96,6 +96,9 @@ public function isAuthorized(Array $user) { 'manage' => $platformAdmin || $mgAdmin, 'pending' => $platformAdmin || $mgAdmin || $recMgr, 'reconcile' => $platformAdmin || $mgAdmin || $recMgr, + // We allow anyone to access select since we don't have a matchgrid context yet. + // If $user has no meaningful permissions, they'll get no menu options. + 'select' => true, 'view' => false ]; @@ -251,4 +254,15 @@ public function reconcile(string $id) { $this->Flash->error(__('match.er.reconcile', [$e->getMessage()])); } } + + /** + * Provide a set of Matchgrids to operate on. + * + * @since COmanage Match v1.0.0 + * @param String $id Matchgrid ID + */ + + public function select() { + $this->set('vv_title', __('match.op.select.mg')); + } } \ No newline at end of file diff --git a/app/src/Controller/PagesController.php b/app/src/Controller/PagesController.php index 63debee9d..58f120679 100644 --- a/app/src/Controller/PagesController.php +++ b/app/src/Controller/PagesController.php @@ -28,7 +28,33 @@ */ class PagesController extends AppController { - + /** + * Callback run prior to the request action. + * + * @since COmanage Match v1.0.0 + * @param Event $event Cake Event + */ + + public function beforeFilter(\Cake\Event\Event $event) { + parent::beforeFilter($event); + + $param = $this->request->getParam('pass.0'); + + if($param == 'home') { + // Allow rendering to get the login button. If we're already logged in, + // redirect to the landing page. + if($this->request->getSession()->read('Auth')) { + $this->redirect([ + 'controller' => 'matchgrids', + 'action' => 'select', + 'plugin' => false + ]); + } + + $this->Auth->allow(['display']); + } + } + /** * Displays a view * diff --git a/app/src/Controller/UsersController.php.not b/app/src/Controller/UsersController.php.not deleted file mode 100644 index fb591f3a4..000000000 --- a/app/src/Controller/UsersController.php.not +++ /dev/null @@ -1,70 +0,0 @@ -Auth->allow(['logout']); - } - - public function login() { - /* - Log::write('debug', 'UsersController::login()'); - - Log::write('debug', 'target=' . $request->session()->read('Auth.target')); - Log::write('debug', 'user=' . $request->session()->read('Auth.external.user')); - - $this->Auth->setUser($user); - return $this->redirect($request->session()->read('Auth.target')); - - /* -debug('in login'); - if ($this->request->is('post')) { - $user = $this->Auth->identify(); -debug($user); - if ($user) { - $this->Auth->setUser($user); - return $this->redirect($this->Auth->redirectUrl()); - } - $this->Flash->error('Your username or password is incorrect.'); - }*/ - } -} diff --git a/app/src/Locale/en_US/default.po b/app/src/Locale/en_US/default.po index c4d67ad0f..a01d436f3 100644 --- a/app/src/Locale/en_US/default.po +++ b/app/src/Locale/en_US/default.po @@ -197,6 +197,9 @@ msgstr "Request ID {0} not found" msgid "match.er.save" msgstr "Save Failed ({0})" +msgid "match.er.unauthorized" +msgstr "{0} does not have any valid permissions" + # XXX rekey? msgid "matchgrid.er.search_type" msgstr "Unknown search type '{0}'" @@ -306,6 +309,9 @@ msgstr "Unique, alphanumeric name for matchgrid (will be prefixed mg_ for actual msgid "match.fd.username" msgstr "Username" +msgid "match.home.welcome" +msgstr "Welcome to {0}." + ### Informational Messages msgid "match.in.matchgrids.none" msgstr "There are no matchgrids currently defined." @@ -336,6 +342,12 @@ msgstr "Edit" msgid "match.op.edit.a" msgstr "Edit {0}" +msgid "match.op.login" +msgstr "Login" + +msgid "match.op.logout" +msgstr "Logout" + msgid "match.op.manage" msgstr "Manage" @@ -360,6 +372,9 @@ msgstr "Assign This Reference ID" msgid "match.op.save" msgstr "Save" +msgid "match.op.select.mg" +msgstr "Matchgrid Selection" + msgid "match.op.skip_to_content" msgstr "Skip to main content" diff --git a/app/src/Template/Element/breadcrumbs.ctp b/app/src/Template/Element/breadcrumbs.ctp index 29d4d61a6..fb5a5360d 100644 --- a/app/src/Template/Element/breadcrumbs.ctp +++ b/app/src/Template/Element/breadcrumbs.ctp @@ -43,7 +43,8 @@ if($this->request->getRequestTarget(false) != '/') { $this->Breadcrumbs->prepend( __('match.meta.match'), - '/' + ['controller' => 'matchgrids', + 'action' => 'select'] ); if(!empty($vv_cur_mg) diff --git a/app/src/Template/Element/menuUser.ctp b/app/src/Template/Element/menuUser.ctp index 93642aebf..e776d14d2 100644 --- a/app/src/Template/Element/menuUser.ctp +++ b/app/src/Template/Element/menuUser.ctp @@ -38,27 +38,27 @@
- + - 'auth', - 'action' => 'login', - 'plugin' => false - ); - print $this->Html->link("XXX LOGIN" . ' ', - $args, array('escape'=>false, 'id' => 'login', 'class' => '')); + print $this->Html->link(__('match.op.login') . ' ', + ['controller' => 'matchgrids', + 'action' => 'select', + 'plugin' => false], + ['escape' => false, + 'id' => 'login', + 'class' => '']); } ?> diff --git a/app/src/Template/Matchgrids/manage.ctp b/app/src/Template/Matchgrids/manage.ctp index a6c64f147..40f63b18d 100644 --- a/app/src/Template/Matchgrids/manage.ctp +++ b/app/src/Template/Matchgrids/manage.ctp @@ -26,9 +26,20 @@ */ declare(strict_types = 1); +?> -print $this->Html->link(__('match.op.reconcile'), - ['controller' => 'Matchgrids', - 'action' => 'pending', - $vv_cur_mg->id], - ['class' => 'reconcilebutton']); +