From a1801688bd7b31036dfcb5efa768a51343506d73 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 27 May 2012 22:36:39 +0200 Subject: [PATCH] Companies: register web page with RECAPTCHA --- apps/companyfront/config/app.yml | 3 ++ apps/companyfront/config/routing.yml | 4 ++ .../modules/register/actions/actions.class.php | 45 ++++++++++++++++++++++ .../modules/register/config/security.yml | 4 ++ apps/companyfront/modules/register/config/view.yml | 20 ++++++++++ .../modules/register/templates/_form.php | 14 +++++++ .../modules/register/templates/indexSuccess.php | 4 ++ .../modules/sfGuardAuth/templates/_signin_form.php | 4 +- lib/form/doctrine/CompaniesRegisterForm.class.php | 27 +++++++++++++ 9 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 apps/companyfront/modules/register/actions/actions.class.php create mode 100644 apps/companyfront/modules/register/config/security.yml create mode 100644 apps/companyfront/modules/register/config/view.yml create mode 100644 apps/companyfront/modules/register/templates/_form.php create mode 100644 apps/companyfront/modules/register/templates/indexSuccess.php create mode 100644 lib/form/doctrine/CompaniesRegisterForm.class.php diff --git a/apps/companyfront/config/app.yml b/apps/companyfront/config/app.yml index c36f791..2d31786 100644 --- a/apps/companyfront/config/app.yml +++ b/apps/companyfront/config/app.yml @@ -18,3 +18,6 @@ all: remember_cookie_path: /companyfront.php # used by sfGuardSecurityUser.class.php. The scope of the Remeber cookie remember_cookie_domain: .localhost + recaptcha: + private_key: 6Lcg9dESAAAAACrrfQ5l9OLp3nq93lN1ra1q-8Kn + public_key: 6Lcg9dESAAAAAG-QQLfE8By9c8ufO8WjuhBMz2-M diff --git a/apps/companyfront/config/routing.yml b/apps/companyfront/config/routing.yml index 41a4507..b105651 100644 --- a/apps/companyfront/config/routing.yml +++ b/apps/companyfront/config/routing.yml @@ -48,3 +48,7 @@ sf_guard_signin: sf_guard_signout: url: /logout param: { module: sfGuardAuth, action: signout } + +register_index: + url: /register + param: { module: register, action: index } diff --git a/apps/companyfront/modules/register/actions/actions.class.php b/apps/companyfront/modules/register/actions/actions.class.php new file mode 100644 index 0000000..7afdf37 --- /dev/null +++ b/apps/companyfront/modules/register/actions/actions.class.php @@ -0,0 +1,45 @@ +getUser()->isAuthenticated()) + { + $this->getUser()->setFlash('notice', 'You are already registered and signed in!'); + $this->redirect('@homepage'); + } + + + $this->form = new CompaniesRegisterForm(); + + if ($request->isMethod('post')) + { + $captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), + 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'), + ); + $this->form->bind(array_merge($request->getParameter($this->form->getName()), array('captcha' => $captcha))); + if ($this->form->isValid()) + { + $user = $this->form->save(); + $user->addPermissionByName('companies'); + $this->getUser()->signIn($user); + + $this->redirect('@homepage'); + } + } + } +} diff --git a/apps/companyfront/modules/register/config/security.yml b/apps/companyfront/modules/register/config/security.yml new file mode 100644 index 0000000..72dcee0 --- /dev/null +++ b/apps/companyfront/modules/register/config/security.yml @@ -0,0 +1,4 @@ + + +index: + is_secure: false diff --git a/apps/companyfront/modules/register/config/view.yml b/apps/companyfront/modules/register/config/view.yml new file mode 100644 index 0000000..4084c6e --- /dev/null +++ b/apps/companyfront/modules/register/config/view.yml @@ -0,0 +1,20 @@ +# You can find more information about this file on the symfony website: +# http://www.symfony-project.org/reference/1_4/en/13-View + +default: + http_metas: + content-type: text/html + + metas: + #title: symfony project + #description: symfony project + #keywords: symfony, project + #language: en + #robots: index, follow + + stylesheets: [inadminpanel/style.css, inadminpanel/niceforms-default.css] + + javascripts: [jquery-1.6.2.min.js, inadminpanel/ddaccordion.js] + + has_layout: true + layout: layoutsfGuardAuth diff --git a/apps/companyfront/modules/register/templates/_form.php b/apps/companyfront/modules/register/templates/_form.php new file mode 100644 index 0000000..b4f9ba0 --- /dev/null +++ b/apps/companyfront/modules/register/templates/_form.php @@ -0,0 +1,14 @@ + + +
+ + + + + + + +
+ +
+
diff --git a/apps/companyfront/modules/register/templates/indexSuccess.php b/apps/companyfront/modules/register/templates/indexSuccess.php new file mode 100644 index 0000000..f756829 --- /dev/null +++ b/apps/companyfront/modules/register/templates/indexSuccess.php @@ -0,0 +1,4 @@ + +

+ + $form)) ?> diff --git a/apps/companyfront/modules/sfGuardAuth/templates/_signin_form.php b/apps/companyfront/modules/sfGuardAuth/templates/_signin_form.php index 924a8c7..b13e241 100644 --- a/apps/companyfront/modules/sfGuardAuth/templates/_signin_form.php +++ b/apps/companyfront/modules/sfGuardAuth/templates/_signin_form.php @@ -15,8 +15,8 @@ - -   + +   diff --git a/lib/form/doctrine/CompaniesRegisterForm.class.php b/lib/form/doctrine/CompaniesRegisterForm.class.php new file mode 100644 index 0000000..049056a --- /dev/null +++ b/lib/form/doctrine/CompaniesRegisterForm.class.php @@ -0,0 +1,27 @@ +User = $this->getObject(); + $newCompanyForm = new CompanyForm($company); + + $this->embedForm('new', $newCompanyForm); + + parent::configure(); + } +} -- 2.1.4