From: Gustavo Martin Morcuende Date: Sun, 27 May 2012 20:36:39 +0000 (+0200) Subject: Companies: register web page with RECAPTCHA X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=a1801688bd7b31036dfcb5efa768a51343506d73;p=mobi%2F.git Companies: register web page with RECAPTCHA --- 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(); + } +}