From adad4da07f96dc5e61e90f4fd449eb2a5dbc3b99 Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Tue, 29 Aug 2017 14:20:06 +0300 Subject: [PATCH 01/14] Cac anonymous users login prompt --- .DS_Store | Bin 6148 -> 8196 bytes auth_prompt/.gitignore | 1 + auth_prompt/auth_prompt.api.php | 26 ++++++++++++++ auth_prompt/auth_prompt.info.yml | 6 ++++ auth_prompt/auth_prompt.module | 17 +++++++++ auth_prompt/auth_prompt.routing.yml | 6 ++++ auth_prompt/auth_prompt.services.yml | 5 +++ .../EventSubscriber/AuthPromptSubscriber.php | 33 ++++++++++++++++++ 8 files changed, 94 insertions(+) create mode 100644 auth_prompt/.gitignore create mode 100644 auth_prompt/auth_prompt.api.php create mode 100644 auth_prompt/auth_prompt.info.yml create mode 100644 auth_prompt/auth_prompt.module create mode 100644 auth_prompt/auth_prompt.routing.yml create mode 100644 auth_prompt/auth_prompt.services.yml create mode 100644 auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php diff --git a/.DS_Store b/.DS_Store index 8509154c52592e400e5dafca9f824778a9bacd7e..a2b75eecfb9343f8cdd14228c75201a6ff1ff9c0 100644 GIT binary patch literal 8196 zcmeHMTWl0n82E5CGqz)AXX?&u z7g!5@^2#eJ@TR;N60h+=jSq$w@j;E&h`tz&zWCsSFBpCCKXYcAURXn7qDJNrKm0Ote>cR=9|7|e{p2?hPx$uH`g111E9 zdB{M>z)A*q?5_q5^5DVblJmQlF1XWa%Sn^Pt@N~Ix?U{yHC9wsty;ZCk}1{5r<0RT zA?aye-tE_NCwXm1^Cr_ldDwBRg|e1DZW@IYYZ!2BPcv;J=R2FaK_;h0Ov8H0Nr@N;k+O?~Dwj)~Hy*ozb&Ysy>S!!&H_Z~WvJ$JtN)a->TVucvI zC7^cMim#Smt~C))W}NKe4;N*KvD}#fK}dLOsQ8IMrTadOk2iC z!PLFUam~#bwr<)JCx~g=GaomNoLq+;^02LC4c|*`RGTH%DvjmS=978TJ1554q;8hk zyV5D0?&J|i=bpN--=uDlq?5dTAZJjn&$D&4HCx+MW!R-PF-?;FmTeCz%J39zIdf&v zvSX*Bj#ygSu$V4OzENkFqK?jprLn_7#xE*(54CA;L_hTRS;{YDPV>pZ> zcpOtWfhInIQ|RF=Ucig^EIx-X;3d3<*YS0H1K-5A@O}J1+*n0Pybp_dDaQ|~R9=$7 zvs!WNZjy|UB)9&nlKf^Z->SO$^$i;~x3+i0d-f$3_Ho(9EfLmYHTfbED)H4*Qio8i z+St?_*{D2FPUj<}H{-0tCC=8&H#at^EzwAXapg#Ub!%HhVMxlB{pz+h>aCzYKCrSQ z5|c^4tkSPWI+bpTl*(3#-aX1*nY7HRL~pM`f;=p<)&4+z8x@6tEHBbtS>?S3Z^K8V zx^Lk-(%R4PE8IaKrLDsz+)PT_g00wwJ4kE0uoJtmcah#6#iKZc<9Gs3;b~IcB&lu+ zEwr(KXYo81NqtY_Go-!eNqd*^C43pL;8lEeneGmj6ekd`m)Bj^864E}UIyT+TQ@I$ z-tkwK`aN1sPu}Z`cqW;%EytdqS@|;~L53n(hN4)S&;?^r1pB1)R4j^Ml3XL*C4vQ! z$B#mPCxQi$kRq5Qr&x2b7>{*!cSJkm@ueY5S{lN5h@w!Br+5;q$ZUY7i=tC z&dA8T`HGk^id() == 0) { + drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'warning'); + } +} + +/** + * @} End + */ diff --git a/auth_prompt/auth_prompt.info.yml b/auth_prompt/auth_prompt.info.yml new file mode 100644 index 0000000..90bd49d --- /dev/null +++ b/auth_prompt/auth_prompt.info.yml @@ -0,0 +1,6 @@ +name: Auth Prompt +type: module +description: Auth Prompt Message +package: message +core: '8.x' +project: 'auth_prompt' \ No newline at end of file diff --git a/auth_prompt/auth_prompt.module b/auth_prompt/auth_prompt.module new file mode 100644 index 0000000..4b3e36d --- /dev/null +++ b/auth_prompt/auth_prompt.module @@ -0,0 +1,17 @@ +id() == 0) { + drupal_set_message(t('Please Login or Register to access all the services.'), 'warning'); + } +} + diff --git a/auth_prompt/auth_prompt.routing.yml b/auth_prompt/auth_prompt.routing.yml new file mode 100644 index 0000000..4548ad0 --- /dev/null +++ b/auth_prompt/auth_prompt.routing.yml @@ -0,0 +1,6 @@ +auth_prompt: + path: 'modules/auth_prompt' + defaults: + _title: 'Auth Promt' + requirements: + _permission: 'access content' \ No newline at end of file diff --git a/auth_prompt/auth_prompt.services.yml b/auth_prompt/auth_prompt.services.yml new file mode 100644 index 0000000..e8fa00d --- /dev/null +++ b/auth_prompt/auth_prompt.services.yml @@ -0,0 +1,5 @@ +services: + auth_prompt.event_subscriber: + class: Drupal\auth_prompt\EventSubscriber\AuthPromptSubscriber + tags: + - {name: event_subscriber} \ No newline at end of file diff --git a/auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php b/auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php new file mode 100644 index 0000000..96fbc1e --- /dev/null +++ b/auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php @@ -0,0 +1,33 @@ +getRequest()->query->get('redirect-me')) { + $event->setResponse(new RedirectResponse('/user/login')); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $events[KernelEvents::REQUEST][] = array('checkForRedirection'); + return $events; + } + +} \ No newline at end of file From e7975389f3635defec77246df1289349a1f6fe63 Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Wed, 30 Aug 2017 01:11:03 +0300 Subject: [PATCH 02/14] EventSub updates --- auth_prompt/auth_prompt.api.php | 26 ----------------- auth_prompt/auth_prompt.info.yml | 4 +-- auth_prompt/composer.json | 14 ++++++++++ auth_prompt/src/AuthPrompt.php | 28 +++++++++++++++++++ .../EventSubscriber/AuthPromptSubscriber.php | 24 ++++++++++------ 5 files changed, 60 insertions(+), 36 deletions(-) delete mode 100644 auth_prompt/auth_prompt.api.php create mode 100644 auth_prompt/composer.json create mode 100644 auth_prompt/src/AuthPrompt.php diff --git a/auth_prompt/auth_prompt.api.php b/auth_prompt/auth_prompt.api.php deleted file mode 100644 index c144a0b..0000000 --- a/auth_prompt/auth_prompt.api.php +++ /dev/null @@ -1,26 +0,0 @@ -id() == 0) { - drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'warning'); - } -} - -/** - * @} End - */ diff --git a/auth_prompt/auth_prompt.info.yml b/auth_prompt/auth_prompt.info.yml index 90bd49d..30ae083 100644 --- a/auth_prompt/auth_prompt.info.yml +++ b/auth_prompt/auth_prompt.info.yml @@ -2,5 +2,5 @@ name: Auth Prompt type: module description: Auth Prompt Message package: message -core: '8.x' -project: 'auth_prompt' \ No newline at end of file +core: 8.x +project: Auth Prompt \ No newline at end of file diff --git a/auth_prompt/composer.json b/auth_prompt/composer.json new file mode 100644 index 0000000..ca02318 --- /dev/null +++ b/auth_prompt/composer.json @@ -0,0 +1,14 @@ +{ + "name": "drupal/auth_prompt", + "type": "drupal-module", + "description": "Auth prompt module for prompting users in Drupal 8.", + "keywords": ["Drupal"], + "license": "GPL-2.0+", + "homepage": "https://www.drupal.org/project/auth_prompt", + "minimum-stability": "dev", + "support": { + "issues": "http://drupal.org/project/issues/auth_prompt", + "source": "http://cgit.drupalcode.org/auth_prompt" + }, + "require": { } +} diff --git a/auth_prompt/src/AuthPrompt.php b/auth_prompt/src/AuthPrompt.php new file mode 100644 index 0000000..fcb38d3 --- /dev/null +++ b/auth_prompt/src/AuthPrompt.php @@ -0,0 +1,28 @@ +referenceID = $referenceID; + } + + public function getReferenceID() + { + return $this->referenceID; + } + + public function myEventDescription() { + return "This is as an auth prompt event"; + } + +} \ No newline at end of file diff --git a/auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php b/auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php index 96fbc1e..d0d49dd 100644 --- a/auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php +++ b/auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php @@ -14,20 +14,28 @@ use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -class auth_prompt_Subscriber implements EventSubscriberInterface { - - public function checkForRedirection(GetResponseEvent $event) { - if ($event->getRequest()->query->get('redirect-me')) { - $event->setResponse(new RedirectResponse('/user/login')); - } - } +/** + * Class ExampleEventSubScriber. + * + * @package Drupal\auth_prompt + */ +class AuthPromptSubscriber implements EventSubscriberInterface { /** * {@inheritdoc} */ public static function getSubscribedEvents() { - $events[KernelEvents::REQUEST][] = array('checkForRedirection'); + $events[KernelEvents::REQUEST][] = array('onKernelRequestAuthenticate', 300); return $events; } + + /** + * Subscriber Callback for the event. + * @param AuthPrompt $event + */ + public function checkForAnonUser(KernelEvents $event) { + drupal_set_message(t('Please Login or Register to access all the services.'), 'warning'); + } + } \ No newline at end of file From 879dc576c2cd050075027cd5107cbca1ba678ccd Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Thu, 31 Aug 2017 01:27:26 +0300 Subject: [PATCH 03/14] adds AuthPromptDispatchForm --- auth_prompt/auth_prompt.routing.yml | 2 +- auth_prompt/composer.json | 14 ----- .../src/Form/AuthPromptDispatchForm.php | 55 +++++++++++++++++++ 3 files changed, 56 insertions(+), 15 deletions(-) delete mode 100644 auth_prompt/composer.json create mode 100644 auth_prompt/src/Form/AuthPromptDispatchForm.php diff --git a/auth_prompt/auth_prompt.routing.yml b/auth_prompt/auth_prompt.routing.yml index 4548ad0..4d8ddfb 100644 --- a/auth_prompt/auth_prompt.routing.yml +++ b/auth_prompt/auth_prompt.routing.yml @@ -1,6 +1,6 @@ auth_prompt: path: 'modules/auth_prompt' defaults: - _title: 'Auth Promt' + _title: 'Auth Prompt' requirements: _permission: 'access content' \ No newline at end of file diff --git a/auth_prompt/composer.json b/auth_prompt/composer.json deleted file mode 100644 index ca02318..0000000 --- a/auth_prompt/composer.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "drupal/auth_prompt", - "type": "drupal-module", - "description": "Auth prompt module for prompting users in Drupal 8.", - "keywords": ["Drupal"], - "license": "GPL-2.0+", - "homepage": "https://www.drupal.org/project/auth_prompt", - "minimum-stability": "dev", - "support": { - "issues": "http://drupal.org/project/issues/auth_prompt", - "source": "http://cgit.drupalcode.org/auth_prompt" - }, - "require": { } -} diff --git a/auth_prompt/src/Form/AuthPromptDispatchForm.php b/auth_prompt/src/Form/AuthPromptDispatchForm.php new file mode 100644 index 0000000..5432e89 --- /dev/null +++ b/auth_prompt/src/Form/AuthPromptDispatchForm.php @@ -0,0 +1,55 @@ + 'textfield', + '#title' => $this->t('Reference'), + '#description' => $this->t('Authentication prompt to an anonymus user of the website.'), + '#maxlength' => 64, + '#size' => 64, + ); + $form['dispatch'] = array( + '#type' => 'submit', + '#value' => $this->t('Dispatch'), + ); + return $form; + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + // AuthPrompt Dispatching + $dispatcher = \Drupal::service('event_dispatcher'); + $event = new AuthPrompt($form_state->getValue('name')); + $dispatcher->dispatch(AuthPrompt::SUBMIT, $event); + } +} From 23f66751aca84a885eca5b717e46e8d51ae301a8 Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Tue, 5 Sep 2017 11:39:31 +0300 Subject: [PATCH 04/14] Adds Form --- .DS_Store | Bin 8196 -> 10244 bytes cac_base/.DS_Store | Bin 6148 -> 8196 bytes cac_base/cac_base.services.yml | 5 ++ cac_base/src/.DS_Store | Bin 0 -> 6148 bytes .../AnonyLoginPromptSubscriber.php | 36 ++++++++++++ .../src/Form/AnonyLoginPromptDispatchForm.php | 55 ++++++++++++++++++ 6 files changed, 96 insertions(+) create mode 100644 cac_base/cac_base.services.yml create mode 100644 cac_base/src/.DS_Store create mode 100644 cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php create mode 100644 cac_base/src/Form/AnonyLoginPromptDispatchForm.php diff --git a/.DS_Store b/.DS_Store index a2b75eecfb9343f8cdd14228c75201a6ff1ff9c0..2fbafef6ba6e3d027ed79f1fe3bcac4313094758 100644 GIT binary patch literal 10244 zcmeHMO>h)N6n-xRn4SO`V%Th!1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ta 118 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGjUEV6q~50$jG!YU^nAr0~wah`~plshWPc3 z4e~6D**Q1_nSttnK!6)axPr87Ed0(qnP0{cWF`Y60|N_)W`YE zg~t*Roj=wmkx4{GxKU0PI#c9>Tx6Fwd0pRMw{^2|fh&cG+>_H&z{0#twsPys4H z1^$o%c5lPR#~>pWpaN9jO9A^n6u7Y_ThKop2tERU1Ilh#`z!$#D}XiGf~deWTES>l zA49C}?O@4sHQ9pEE}FxK=9AT?7??)8Xh8zg>R_M(RG?Gf5cy>H{~7+%{NJ@Or2getRequest(); + $redirect_url = $request->server->get('REQUEST_URI', null); + drupal_set_message(t('fffffffffff'), 'warning'); + } + + /** + * Registers the methods in this class that should be listeners. + * + * @return array + * An array of event listener definitions. + */ + public static function getSubscribedEvents() { + $events[KernelEvents::RESPONSE][] = ['anonymousLoginPrompt']; + return $events; + } +} \ No newline at end of file diff --git a/cac_base/src/Form/AnonyLoginPromptDispatchForm.php b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php new file mode 100644 index 0000000..3821839 --- /dev/null +++ b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php @@ -0,0 +1,55 @@ + 'textfield', + '#title' => $this->t('Reference'), + '#description' => $this->t('Authentication prompt to an anonymus user of the website.'), + '#maxlength' => 64, + '#size' => 64, + ); + $form['dispatch'] = array( + '#type' => 'submit', + '#value' => $this->t('Dispatch'), + ); + return $form; + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + // AnonyLoginPrompt Dispatching + $dispatcher = \Drupal::service('event_dispatcher'); + $event = new AnonyLoginPrompt($form_state->getValue('name')); + $dispatcher->dispatch(AnonyLoginPrompt::SUBMIT, $event); + } +} From 060533431c8c894384963ce4c8962254ef289900 Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Tue, 5 Sep 2017 11:42:01 +0300 Subject: [PATCH 05/14] removes unused files --- auth_prompt/.gitignore | 1 - auth_prompt/auth_prompt.info.yml | 6 -- auth_prompt/auth_prompt.module | 17 ------ auth_prompt/auth_prompt.routing.yml | 6 -- auth_prompt/auth_prompt.services.yml | 5 -- auth_prompt/src/AuthPrompt.php | 28 ---------- .../EventSubscriber/AuthPromptSubscriber.php | 41 -------------- .../src/Form/AuthPromptDispatchForm.php | 55 ------------------- 8 files changed, 159 deletions(-) delete mode 100644 auth_prompt/.gitignore delete mode 100644 auth_prompt/auth_prompt.info.yml delete mode 100644 auth_prompt/auth_prompt.module delete mode 100644 auth_prompt/auth_prompt.routing.yml delete mode 100644 auth_prompt/auth_prompt.services.yml delete mode 100644 auth_prompt/src/AuthPrompt.php delete mode 100644 auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php delete mode 100644 auth_prompt/src/Form/AuthPromptDispatchForm.php diff --git a/auth_prompt/.gitignore b/auth_prompt/.gitignore deleted file mode 100644 index 496ee2c..0000000 --- a/auth_prompt/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store \ No newline at end of file diff --git a/auth_prompt/auth_prompt.info.yml b/auth_prompt/auth_prompt.info.yml deleted file mode 100644 index 30ae083..0000000 --- a/auth_prompt/auth_prompt.info.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: Auth Prompt -type: module -description: Auth Prompt Message -package: message -core: 8.x -project: Auth Prompt \ No newline at end of file diff --git a/auth_prompt/auth_prompt.module b/auth_prompt/auth_prompt.module deleted file mode 100644 index 4b3e36d..0000000 --- a/auth_prompt/auth_prompt.module +++ /dev/null @@ -1,17 +0,0 @@ -id() == 0) { - drupal_set_message(t('Please Login or Register to access all the services.'), 'warning'); - } -} - diff --git a/auth_prompt/auth_prompt.routing.yml b/auth_prompt/auth_prompt.routing.yml deleted file mode 100644 index 4d8ddfb..0000000 --- a/auth_prompt/auth_prompt.routing.yml +++ /dev/null @@ -1,6 +0,0 @@ -auth_prompt: - path: 'modules/auth_prompt' - defaults: - _title: 'Auth Prompt' - requirements: - _permission: 'access content' \ No newline at end of file diff --git a/auth_prompt/auth_prompt.services.yml b/auth_prompt/auth_prompt.services.yml deleted file mode 100644 index e8fa00d..0000000 --- a/auth_prompt/auth_prompt.services.yml +++ /dev/null @@ -1,5 +0,0 @@ -services: - auth_prompt.event_subscriber: - class: Drupal\auth_prompt\EventSubscriber\AuthPromptSubscriber - tags: - - {name: event_subscriber} \ No newline at end of file diff --git a/auth_prompt/src/AuthPrompt.php b/auth_prompt/src/AuthPrompt.php deleted file mode 100644 index fcb38d3..0000000 --- a/auth_prompt/src/AuthPrompt.php +++ /dev/null @@ -1,28 +0,0 @@ -referenceID = $referenceID; - } - - public function getReferenceID() - { - return $this->referenceID; - } - - public function myEventDescription() { - return "This is as an auth prompt event"; - } - -} \ No newline at end of file diff --git a/auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php b/auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php deleted file mode 100644 index d0d49dd..0000000 --- a/auth_prompt/src/EventSubscriber/AuthPromptSubscriber.php +++ /dev/null @@ -1,41 +0,0 @@ -Login or Register to access all the services.'), 'warning'); - } - -} \ No newline at end of file diff --git a/auth_prompt/src/Form/AuthPromptDispatchForm.php b/auth_prompt/src/Form/AuthPromptDispatchForm.php deleted file mode 100644 index 5432e89..0000000 --- a/auth_prompt/src/Form/AuthPromptDispatchForm.php +++ /dev/null @@ -1,55 +0,0 @@ - 'textfield', - '#title' => $this->t('Reference'), - '#description' => $this->t('Authentication prompt to an anonymus user of the website.'), - '#maxlength' => 64, - '#size' => 64, - ); - $form['dispatch'] = array( - '#type' => 'submit', - '#value' => $this->t('Dispatch'), - ); - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - // AuthPrompt Dispatching - $dispatcher = \Drupal::service('event_dispatcher'); - $event = new AuthPrompt($form_state->getValue('name')); - $dispatcher->dispatch(AuthPrompt::SUBMIT, $event); - } -} From 7802ddadcf16cd6b81c56803e22116a20e410b6f Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Wed, 6 Sep 2017 20:05:13 +0300 Subject: [PATCH 06/14] Updates the status message --- .DS_Store | Bin 10244 -> 8196 bytes .../AnonyLoginPromptSubscriber.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.DS_Store b/.DS_Store index 2fbafef6ba6e3d027ed79f1fe3bcac4313094758..e9db4127700fb930e41072666c3d8adc577159d8 100644 GIT binary patch delta 124 zcmZn(XmOBWU|?W$DortDU;r^WfEYvza8E20o2aKK$_kPP@);PC7!nzZ8B&wViwiau zPGg_gz`L29gN1{Ub@Bsokw&ze*qn&h)N6n-xRn4SO`V%Th!1XhwrfCUorhy2JwLI43l5=i*bu)8ymDR+0`&TPVu zfhc<8$G?l92bJ;%yoh>G^kkKSdO*bjEcKwJR_VbXJm^VZch5%HWK&pbVc~Su^qYRK z-^}!zZ{FA40|2-zt=9qs0YIUHOKlug!xV1k$B>feY9^3G@(1XG9!P-&36fs%BH%^9 zi+~paF9Kc!{)-VH&gMlakkYHY2zU|jA}|;Mo*#mAa2a;xfRrM2P$iZCB=bov3Z2tB zK==e*8FuA>l){y+DOV5Zx}v+pK2Xya@?g|CP-N`Q~x&wx# z^lC2xUId0lfUn&PAOdM{p!=%zyA$oRd!lhGN)-c;93i?{0t&N6d^GoPbvqW1(gSmk91)4{tZj=~i7WRua`m)(n`P|s5}DXt{4;h1 zzU9TOE4nl-Z5tbmc*HS#jh2XG*j-woO+j20vy$smMlS`dBWA_Zi6mJj#v<`pnmQXx zImog6nQFtwt3_PnNr z;q&7s6l$!96?gQSwi%5Z8~aS%>E0Z%V@6UplRLN2OGrBA4%0}ni5Oz-$w*$q3(pJ05`9;jvNv|hC zk8G2U56-vPw?xs-D0lN4uZh^sx*j9x-g{}8&$pTDm+HEqD~eJPu9k4A2-nCHjnh&o zgy1%4g)I<+B=o^SI0T2`C_D=%;bk}t@4&n89=s3d;1YZapTXzw4g3H^3pi|swNiQR6J=)MRlmQ zabbAyJ!ZYQtAKSSngoa>N(6c`=#Yr@mH0~olUaE#oNpw&8M_n?ac%7R(h|RKYA_Jc zIC2!xtgH$!4GGyyG-p(iHIHok!fZ~Uh7o?XQKA{BV+{%+RU0j>^VtGMSl05TbulAA zu4dX8aiOJ?8PkBVVX&7Ic~8R$c%4x95nLdweF@(Y+I}UZjX@24gtP!o#&W!cur?EC zVF(+pz*{S>z?FC>ZoqcjNT}ORsEeVFJJ7-&OrcHa+lTuJdk+xy4&f1e7$3n$@mLn_ zR%8$-B_7X>yM)!!qNkl0z$a(l-hVDMQcwLFd-il+Ya;G#OC{r0awpxDe=`bw!x1{V zAWG5(<3=U9Ap^aV-i8?CBhr;x;9p*>5?u{LD1V=@hDkYt9H!w=zEX?SzsOgdXy`-r z4{{apmZS%@%%6j={AK=ZzT!zrt@2Oj-?~UQf??E|DkTkDa+c8e=c=_l0my75RrP8k z|LQYYNh*uf1qvI?bW*q2KLTI*{loJW8zd}|H0IEnX(em}gZ{!CAi6pXN8lJ7hnL_K zyh&trhREsz_>jozEBKno>RTeKpWrh5f+)yp9QyHQoQ9P|Su?Q?>#>ni$Rb>ht&}`g z;X3TZ&A1h}QQ}Bol2XSmH(@-4kKjTEC zm}>g0nuY~S2H)R5$y92&WTfo*Scbo}v7D+T{Y(v(m%B_Q*r>8x6+Fco)sxdZ!TO!)-hsk#hc;DWW9=~t^sq;&;;oX!rRAi z5xyX-eNQ<14SvVbSV%Ngie*GoQ)p5&L(tT0LfL#VF=`e_TY>9cn%X2LN1Ub%LYt&1 z2m4)`I)Df9uuD`&uZgIJATEm}Bxt?bi@=Q?fl+dJLB9XLJoo?q8#@Tz=)4I0&m(~O zEp08!CxKPEraJ|@$rv~4S7rQB>b2n3jJ?!=ykW#pl gpKvEBck}=Cp8?tPDsTPot^aSVP3|Fc-0b!LAHKE!w*UYD diff --git a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php index 304e0ea..a97179e 100644 --- a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php +++ b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php @@ -20,7 +20,7 @@ class AnonyLoginPromptSubscriber implements EventSubscriberInterface { public function anonymousLoginPrompt(FilterResponseEvent $event) { $request = $event->getRequest(); $redirect_url = $request->server->get('REQUEST_URI', null); - drupal_set_message(t('fffffffffff'), 'warning'); + drupal_set_message(t('Please sign in or register an account to access all the services offered by the Commission'), 'status'); } /** From d50b3d235117a619a7aa6d4a5b442929acde7bad Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Thu, 7 Sep 2017 09:45:47 +0300 Subject: [PATCH 07/14] updates the subscriber event --- .DS_Store | Bin 8196 -> 0 bytes .gitignore | 1 + cac_base/.DS_Store | Bin 8196 -> 0 bytes cac_base/src/.DS_Store | Bin 6148 -> 0 bytes .../AnonyLoginPromptSubscriber.php | 31 +++++++++++++----- .../src/Form/AnonyLoginPromptDispatchForm.php | 2 +- 6 files changed, 25 insertions(+), 9 deletions(-) delete mode 100644 .DS_Store create mode 100644 .gitignore delete mode 100644 cac_base/.DS_Store delete mode 100644 cac_base/src/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index e9db4127700fb930e41072666c3d8adc577159d8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMNo*WN6#d^z(%rV>wsCMf@gzfR%O)9v9dFXXUtMi0@q)w!h|(oh{p!Ee z^6IHde+B@sH*d58XaFElW74O9#NUMFuGu0Kvf z82pKnsocBNBNACadP1ZqNAsdP*7blS;eXwk0FozPB7>J8}$KJlZv>y2cYO>^@t^wetF z4A=J<1~Vi{s*5*?lb7q_Euu$9TLTZ!Lox(&z#t13;38at%WxI0!MpGtd<>t$4fq_s zfG^=&_#S?MAK@qX1%8F!;CDn+umnp{!~5_M)?))6#x`unPVB90~w{WoO%rj#?VqVk@qy$9+VkF<1jpWHaVO-FVcrEcYsPaVMxpEK*65L_jm*6iD_ zL?(z$Y-uyU*Lkn*=IoZ%xc9+mB%*T8h)=mbq7b8H-_}%5wt~PCYbHw}kyqGSk17$h zn0PAUI=d7_Eg~Wd>#^fx-9?lY*7$z1f-L_d&bDSMUm6-Nd-TO^my?9pe@fIoopVvt(Om>g{3S*By>Pp;*7h^Z$XJfB(P3 zcNs1}L?A@q?-0PE{zQK-dF*u0^ISVh^$b;BxZkRfeh4+(h3oxvoaDwIhSZM+ws;^{ Xg(M4=fBlDmn(+M(-+!NacXjg@`jO8z diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/cac_base/.DS_Store b/cac_base/.DS_Store deleted file mode 100644 index 6b6e4c9d5b88e310032ec9bb2118b55d4803a747..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHLU2GLa6h5adWp<%-C%NWO@wIf@t;&#Y1wX%>=1@&|C>Shg69WL-Zy%Q{xX z5r`uYM<9+s9Dz6j|Aq+AnJo&N=iFDLaUDk>j==vi0^<9Sq({hfBqx-VpAM>I3P7@g z)Ur^U@&M_RjAS~J6G}=~np0&D7`bAUVxV%T@uV;(nU3UylFA)WxdTQkW0awwT%G)q z(i||YWL(D)h$ApN0wQ;>gdF(b!O@cZ{j=jYscbrZ|VD;88PWSYjbD)v)!)!)rTzFEky`&fj5vsNeA{zu4gyJS&j%^qAps z@|6o^xG^@?oNC$Jlx%5k9&bvHwY8<1lC3RU#>W|3+1R|j`^fOA(_?4GpS`4jVf1l; z>Jp%@m!cf)&3mrz9V5N)DTe^^kh|mV;`$ueHLXgU1AFw&^8Nn|_Fff3!meo3H_piIxln)nh2g1oqhScUqAM2c~T2jsR z8ojoE)CrudYws^QR(O2S405(-Io`2@6hbd_jyiT;TZ&CupJxu+lPgx%aU)^eGoKgZ z4Q!y0b)G3W;VHF7y>YL`-)Dy`dc!@wC1$kbh*57eGBzaioq3yTYmzUiu6kgdq4x!Z zm77eHnx>7q-gkod%>zwonm6gje%H*}F1Iu$jkdJuM*paS%y&h~tu?wakn@L!2}(dZ z0oq6#9gJUNhsDCX%^=)6VtZokm31q+>J4L1=-VyJwisg#>2)f2628X8*=oRAXoYRi z1A|~e5zfLnI1g{Z6}So?z{l_fdl}!2R?~Au^abcKMvwS96}49Mi+;*=L;tdVn%&3 zk>G+hOm^>Uq;46}nu(u;p|4MnrO9}?>?R)8n;9{aFHobc`WB72%PZ9ABl=cG6y=q2 zs_m7Nc9IFoN}fB diff --git a/cac_base/src/.DS_Store b/cac_base/src/.DS_Store deleted file mode 100644 index 1149b42b8a9f8d53e853e6617d9281d2673d8072..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~J!-^2427kv3qu;0TTZhF$PEVL-3#mmmc*rlAtC)7Jx@ObGMhSt@C4E~(u^>E zg~t*Roj=wmkx4{GxKU0PI#c9>Tx6Fwd0pRMw{^2|fh&cG+>_H&z{0#twsPys4H z1^$o%c5lPR#~>pWpaN9jO9A^n6u7Y_ThKop2tERU1Ilh#`z!$#D}XiGf~deWTES>l zA49C}?O@4sHQ9pEE}FxK=9AT?7??)8Xh8zg>R_M(RG?Gf5cy>H{~7+%{NJ@Or2getRequest(); $redirect_url = $request->server->get('REQUEST_URI', null); - drupal_set_message(t('Please sign in or register an account to access all the services offered by the Commission'), 'status'); + if ($current_user->id() == 0) { + drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'status'); + } } /** diff --git a/cac_base/src/Form/AnonyLoginPromptDispatchForm.php b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php index 3821839..8d2b2d8 100644 --- a/cac_base/src/Form/AnonyLoginPromptDispatchForm.php +++ b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php @@ -32,7 +32,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['name'] = array( '#type' => 'textfield', '#title' => $this->t('Reference'), - '#description' => $this->t('Authentication prompt to an anonymus user of the website.'), + '#description' => $this->t('Reminds the anonymous user to sign and or register an account.'), '#maxlength' => 64, '#size' => 64, ); From 9bf7db3a7449a793354df28262af15099dac175c Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Thu, 7 Sep 2017 10:10:22 +0300 Subject: [PATCH 08/14] defines our event class --- cac_base/src/AnonyLoginPrompt.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 cac_base/src/AnonyLoginPrompt.php diff --git a/cac_base/src/AnonyLoginPrompt.php b/cac_base/src/AnonyLoginPrompt.php new file mode 100644 index 0000000..157b568 --- /dev/null +++ b/cac_base/src/AnonyLoginPrompt.php @@ -0,0 +1,23 @@ +referenceID = $referenceID; + } + + public function getReferenceID() { + return $this->referenceID; + } + + public function myEventDescription() { + return "An event to prompt the user to sign up/register an acount."; + } +} \ No newline at end of file From 65307abc138fd42ba7175015476430601c459ef3 Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Thu, 7 Sep 2017 11:00:40 +0300 Subject: [PATCH 09/14] attempts the path to dispaly the prompt messages --- cac_base/cac_base.routing.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cac_base/cac_base.routing.yml b/cac_base/cac_base.routing.yml index 9ad47d1..58e7099 100644 --- a/cac_base/cac_base.routing.yml +++ b/cac_base/cac_base.routing.yml @@ -4,3 +4,20 @@ config_cac_base.description: _controller: '\Drupal\cac_base\Controller\NodeTypeCompanyRegistration::description' requirements: _permission: 'access content' + +anonyloginprompt.services: + path: '/node/69' + defaults: + _title: 'Login Prompt' + _form: '\Drupal\cac_base\Form\AnonyLoginPromptDispatchForm' + requirements: + _user_is_logged_in: 'FALSE' + +anonyloginprompt.service_page: + path: '/node/97' + defaults: + _title: 'Login Prompt' + _form: '\Drupal\cac_base\Form\AnonyLoginPromptDispatchForm' + requirements: + _user_is_logged_in: 'FALSE' + From b8dc3d6cba69a72db1a8608c01e422124bd62a3a Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Thu, 7 Sep 2017 11:39:11 +0300 Subject: [PATCH 10/14] updates prompt_message --- cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php index 3d53c22..aa36313 100644 --- a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php +++ b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php @@ -33,9 +33,7 @@ public static function getSubscribedEvents() { public function anonymousLoginPrompt(AnonyLoginPrompt $event) { $request = $event->getRequest(); $redirect_url = $request->server->get('REQUEST_URI', null); - if ($current_user->id() == 0) { - drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'status'); - } + drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'status'); } /** From 78af482942a9b6fe339be7c53ac714bc758e3f05 Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Thu, 7 Sep 2017 11:42:28 +0300 Subject: [PATCH 11/14] updates prompt_message --- cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php index aa36313..d169c3d 100644 --- a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php +++ b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php @@ -31,8 +31,6 @@ public static function getSubscribedEvents() { * @param AnonyLoginPrompt $event */ public function anonymousLoginPrompt(AnonyLoginPrompt $event) { - $request = $event->getRequest(); - $redirect_url = $request->server->get('REQUEST_URI', null); drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'status'); } From 716e46af4cea76bbc5bff4e219f3b825af2f0ef4 Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Thu, 7 Sep 2017 14:23:25 +0300 Subject: [PATCH 12/14] updates subscriber --- cac_base/cac_base.routing.yml | 4 ++-- .../AnonyLoginPromptSubscriber.php | 4 ++-- .../src/Form/AnonyLoginPromptDispatchForm.php | 16 +++------------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/cac_base/cac_base.routing.yml b/cac_base/cac_base.routing.yml index 58e7099..ba8a310 100644 --- a/cac_base/cac_base.routing.yml +++ b/cac_base/cac_base.routing.yml @@ -8,7 +8,7 @@ config_cac_base.description: anonyloginprompt.services: path: '/node/69' defaults: - _title: 'Login Prompt' + _title: 'Services' _form: '\Drupal\cac_base\Form\AnonyLoginPromptDispatchForm' requirements: _user_is_logged_in: 'FALSE' @@ -16,7 +16,7 @@ anonyloginprompt.services: anonyloginprompt.service_page: path: '/node/97' defaults: - _title: 'Login Prompt' + _title: 'Services' _form: '\Drupal\cac_base\Form\AnonyLoginPromptDispatchForm' requirements: _user_is_logged_in: 'FALSE' diff --git a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php index d169c3d..f05480c 100644 --- a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php +++ b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php @@ -41,7 +41,7 @@ public function anonymousLoginPrompt(AnonyLoginPrompt $event) { * An array of event listener definitions. */ public static function getSubscribedEvents() { - $events[KernelEvents::RESPONSE][] = ['anonymousLoginPrompt']; - return $events; + $events[KernelEvents::RESPONSE][] = ['anonymousLoginPrompt']; + return $events; } } \ No newline at end of file diff --git a/cac_base/src/Form/AnonyLoginPromptDispatchForm.php b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php index 8d2b2d8..be69a12 100644 --- a/cac_base/src/Form/AnonyLoginPromptDispatchForm.php +++ b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php @@ -29,19 +29,8 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $form['name'] = array( - '#type' => 'textfield', - '#title' => $this->t('Reference'), - '#description' => $this->t('Reminds the anonymous user to sign and or register an account.'), - '#maxlength' => 64, - '#size' => 64, - ); - $form['dispatch'] = array( - '#type' => 'submit', - '#value' => $this->t('Dispatch'), - ); - return $form; - } + drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'status'); + } /** * {@inheritdoc} @@ -53,3 +42,4 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $dispatcher->dispatch(AnonyLoginPrompt::SUBMIT, $event); } } + From 2ab9c4fced1d22bc145f1c06944ade273e2cf830 Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Thu, 7 Sep 2017 16:05:09 +0300 Subject: [PATCH 13/14] updates auth_check --- cac_base/cac_base.routing.yml | 4 ++-- .../EventSubscriber/AnonyLoginPromptSubscriber.php | 10 ++++++---- cac_base/src/Form/AnonyLoginPromptDispatchForm.php | 11 +++++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cac_base/cac_base.routing.yml b/cac_base/cac_base.routing.yml index ba8a310..87034b2 100644 --- a/cac_base/cac_base.routing.yml +++ b/cac_base/cac_base.routing.yml @@ -11,7 +11,7 @@ anonyloginprompt.services: _title: 'Services' _form: '\Drupal\cac_base\Form\AnonyLoginPromptDispatchForm' requirements: - _user_is_logged_in: 'FALSE' + _permission: 'access content' anonyloginprompt.service_page: path: '/node/97' @@ -19,5 +19,5 @@ anonyloginprompt.service_page: _title: 'Services' _form: '\Drupal\cac_base\Form\AnonyLoginPromptDispatchForm' requirements: - _user_is_logged_in: 'FALSE' + _permission: 'access content' diff --git a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php index f05480c..d307bd5 100644 --- a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php +++ b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php @@ -21,9 +21,9 @@ class AnonyLoginPromptSubscriber implements EventSubscriberInterface { * {@inheritdoc} */ public static function getSubscribedEvents() { - $events[ConfigEvents::SAVE][] = array('onSavingConfig', 800); - $events[AnonyLoginPrompt::SUBMIT][] = array('anonymousLoginPrompt', 800); - return $events; + $events[ConfigEvents::SAVE][] = array('onSavingConfig', 800); + $events[AnonyLoginPrompt::SUBMIT][] = array('anonymousLoginPrompt', 800); + return $events; } /** @@ -31,7 +31,9 @@ public static function getSubscribedEvents() { * @param AnonyLoginPrompt $event */ public function anonymousLoginPrompt(AnonyLoginPrompt $event) { - drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'status'); + if (\Drupal::currentUser()->isAnonymous()) { + drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'status'); + } } /** diff --git a/cac_base/src/Form/AnonyLoginPromptDispatchForm.php b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php index be69a12..089c079 100644 --- a/cac_base/src/Form/AnonyLoginPromptDispatchForm.php +++ b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php @@ -22,14 +22,18 @@ class AnonyLoginPromptDispatchForm extends FormBase { * {@inheritdoc} */ public function getFormId() { - return 'anony_login_dispatch_form'; + if (\Drupal::currentUser()->isAnonymous()) { + return 'anony_login_dispatch_form'; + } } /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state) { - drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'status'); + public function buildForm(array $form, FormStateInterface $form_state) { + if (\Drupal::currentUser()->isAnonymous()) { + drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'warning'); + } } /** @@ -42,4 +46,3 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $dispatcher->dispatch(AnonyLoginPrompt::SUBMIT, $event); } } - From 557266d1132b5def8221ccacc841266bd2f38f9c Mon Sep 17 00:00:00 2001 From: Samson Paul Date: Sun, 10 Sep 2017 15:13:41 +0300 Subject: [PATCH 14/14] sends the anon-user auth prompt --- cac_base/cac_base.routing.yml | 17 ------- cac_base/src/AnonyLoginPrompt.php | 23 --------- .../AnonyLoginPromptSubscriber.php | 37 +++++--------- .../src/Form/AnonyLoginPromptDispatchForm.php | 48 ------------------- 4 files changed, 13 insertions(+), 112 deletions(-) delete mode 100644 cac_base/src/AnonyLoginPrompt.php delete mode 100644 cac_base/src/Form/AnonyLoginPromptDispatchForm.php diff --git a/cac_base/cac_base.routing.yml b/cac_base/cac_base.routing.yml index 87034b2..9ad47d1 100644 --- a/cac_base/cac_base.routing.yml +++ b/cac_base/cac_base.routing.yml @@ -4,20 +4,3 @@ config_cac_base.description: _controller: '\Drupal\cac_base\Controller\NodeTypeCompanyRegistration::description' requirements: _permission: 'access content' - -anonyloginprompt.services: - path: '/node/69' - defaults: - _title: 'Services' - _form: '\Drupal\cac_base\Form\AnonyLoginPromptDispatchForm' - requirements: - _permission: 'access content' - -anonyloginprompt.service_page: - path: '/node/97' - defaults: - _title: 'Services' - _form: '\Drupal\cac_base\Form\AnonyLoginPromptDispatchForm' - requirements: - _permission: 'access content' - diff --git a/cac_base/src/AnonyLoginPrompt.php b/cac_base/src/AnonyLoginPrompt.php deleted file mode 100644 index 157b568..0000000 --- a/cac_base/src/AnonyLoginPrompt.php +++ /dev/null @@ -1,23 +0,0 @@ -referenceID = $referenceID; - } - - public function getReferenceID() { - return $this->referenceID; - } - - public function myEventDescription() { - return "An event to prompt the user to sign up/register an acount."; - } -} \ No newline at end of file diff --git a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php index d307bd5..ed254de 100644 --- a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php +++ b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php @@ -1,39 +1,28 @@ getRequest(); + $redirect_url = $request->server->get('REQUEST_URI', null); if (\Drupal::currentUser()->isAnonymous()) { - drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'status'); - } + drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'warning'); + } } /** @@ -43,7 +32,7 @@ public function anonymousLoginPrompt(AnonyLoginPrompt $event) { * An array of event listener definitions. */ public static function getSubscribedEvents() { - $events[KernelEvents::RESPONSE][] = ['anonymousLoginPrompt']; - return $events; + $events[KernelEvents::RESPONSE][] = ['anonymousLoginPrompt']; + return $events; } } \ No newline at end of file diff --git a/cac_base/src/Form/AnonyLoginPromptDispatchForm.php b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php deleted file mode 100644 index 089c079..0000000 --- a/cac_base/src/Form/AnonyLoginPromptDispatchForm.php +++ /dev/null @@ -1,48 +0,0 @@ -isAnonymous()) { - return 'anony_login_dispatch_form'; - } - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, FormStateInterface $form_state) { - if (\Drupal::currentUser()->isAnonymous()) { - drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'warning'); - } - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - // AnonyLoginPrompt Dispatching - $dispatcher = \Drupal::service('event_dispatcher'); - $event = new AnonyLoginPrompt($form_state->getValue('name')); - $dispatcher->dispatch(AnonyLoginPrompt::SUBMIT, $event); - } -}