From 975795544e2d908e9d1596ec76f0e2bda2ab16ae Mon Sep 17 00:00:00 2001 From: kushthedude Date: Mon, 24 Jun 2019 18:14:13 +0530 Subject: [PATCH 1/2] Addition of Fields for reCAPTCHA --- .../admin/settings/system/captcha-form.js | 4 + app/models/custom-form.js | 2 + app/models/setting.js | 125 +++++++++--------- .../forms/admin/settings/system-form.hbs | 5 +- .../admin/settings/system/captcha-form.hbs | 36 +++++ .../settings/system/captcha-form-test.js | 16 +++ 6 files changed, 124 insertions(+), 64 deletions(-) create mode 100644 app/components/forms/admin/settings/system/captcha-form.js create mode 100644 app/templates/components/forms/admin/settings/system/captcha-form.hbs create mode 100644 tests/integration/components/forms/admin/settings/system/captcha-form-test.js diff --git a/app/components/forms/admin/settings/system/captcha-form.js b/app/components/forms/admin/settings/system/captcha-form.js new file mode 100644 index 00000000000..bb93d73f350 --- /dev/null +++ b/app/components/forms/admin/settings/system/captcha-form.js @@ -0,0 +1,4 @@ +import Component from '@ember/component'; + +export default Component.extend({ +}); diff --git a/app/models/custom-form.js b/app/models/custom-form.js index d1c13e8db45..c87f8e897f0 100644 --- a/app/models/custom-form.js +++ b/app/models/custom-form.js @@ -4,6 +4,7 @@ import ModelBase from 'open-event-frontend/models/base'; import { belongsTo } from 'ember-data/relationships'; export default ModelBase.extend({ + fieldIdentifier : attr('string'), form : attr('string'), type : attr('string', { defaultValue: 'text' }), @@ -86,6 +87,7 @@ export default ModelBase.extend({ } else { name = this.get(`attendee.${name}`); } + return name; }), diff --git a/app/models/setting.js b/app/models/setting.js index b8479ba198d..b228b8f5a25 100644 --- a/app/models/setting.js +++ b/app/models/setting.js @@ -8,67 +8,70 @@ export default ModelBase.extend({ * Attributes */ - appEnvironment : attr('string'), - appName : attr('string'), - tagline : attr('string'), - secret : attr('string'), - storagePlace : attr('string'), - awsKey : attr('string'), - awsSecret : attr('string'), - awsBucketName : attr('string'), - awsRegion : attr('string'), - gsKey : attr('string'), - gsSecret : attr('string'), - gsBucketName : attr('string'), - googleClientId : attr('string'), - googleClientSecret : attr('string'), - fbClientId : attr('string'), - fbClientSecret : attr('string'), - twConsumerKey : attr('string'), - twConsumerSecret : attr('string'), - inClientId : attr('string'), - inClientSecret : attr('string'), - paypalMode : attr('string'), - paypalClient : attr('string'), - paypalSecret : attr('string'), - paypalSandboxClient : attr('string'), - paypalSandboxSecret : attr('string'), - alipaySecretKey : attr('string'), - alipayPublishableKey : attr('string'), - omiseMode : attr('string'), - omiseTestPublic : attr('string'), - omiseTestSecret : attr('string'), - omiseLivePublic : attr('string'), - omiseLiveSecret : attr('string'), - stripeClientId : attr('string'), - stripeSecretKey : attr('string'), - stripePublishableKey : attr('string'), - isPaypalActivated : attr('boolean'), - isStripeActivated : attr('boolean'), - isAliPayActivated : attr('boolean'), - isOmiseActivated : attr('boolean'), - emailService : attr('string'), - emailFrom : attr('string'), - emailFromName : attr('string'), - sendgridKey : attr('string'), - smtpHost : attr('string'), - smtpUsername : attr('string'), - smtpPassword : attr('string'), - smtpPort : attr('string'), - smtpEncryption : attr('string'), - analyticsKey : attr('string'), - googleUrl : attr('string'), - githubUrl : attr('string'), - twitterUrl : attr('string'), - supportUrl : attr('string'), - facebookUrl : attr('string'), - youtubeUrl : attr('string'), - androidAppUrl : attr('string'), - frontendUrl : attr('string'), - webAppUrl : attr('string'), - staticDomain : attr('string'), - cookiePolicy : attr('string'), - cookiePolicyLink : attr('string'), + appEnvironment : attr('string'), + appName : attr('string'), + tagline : attr('string'), + secret : attr('string'), + storagePlace : attr('string'), + awsKey : attr('string'), + awsSecret : attr('string'), + awsBucketName : attr('string'), + awsRegion : attr('string'), + gsKey : attr('string'), + gsSecret : attr('string'), + gsBucketName : attr('string'), + isGoogleRecaptchaEnabled : attr('boolean', { defaultValue: false }), + googleRecaptchaSitekey : attr('string'), + googleRecaptchaSecretkey : attr('string'), + googleClientId : attr('string'), + googleClientSecret : attr('string'), + fbClientId : attr('string'), + fbClientSecret : attr('string'), + twConsumerKey : attr('string'), + twConsumerSecret : attr('string'), + inClientId : attr('string'), + inClientSecret : attr('string'), + paypalMode : attr('string'), + paypalClient : attr('string'), + paypalSecret : attr('string'), + paypalSandboxClient : attr('string'), + paypalSandboxSecret : attr('string'), + alipaySecretKey : attr('string'), + alipayPublishableKey : attr('string'), + omiseMode : attr('string'), + omiseTestPublic : attr('string'), + omiseTestSecret : attr('string'), + omiseLivePublic : attr('string'), + omiseLiveSecret : attr('string'), + stripeClientId : attr('string'), + stripeSecretKey : attr('string'), + stripePublishableKey : attr('string'), + isPaypalActivated : attr('boolean'), + isStripeActivated : attr('boolean'), + isAliPayActivated : attr('boolean'), + isOmiseActivated : attr('boolean'), + emailService : attr('string'), + emailFrom : attr('string'), + emailFromName : attr('string'), + sendgridKey : attr('string'), + smtpHost : attr('string'), + smtpUsername : attr('string'), + smtpPassword : attr('string'), + smtpPort : attr('string'), + smtpEncryption : attr('string'), + analyticsKey : attr('string'), + googleUrl : attr('string'), + githubUrl : attr('string'), + twitterUrl : attr('string'), + supportUrl : attr('string'), + facebookUrl : attr('string'), + youtubeUrl : attr('string'), + androidAppUrl : attr('string'), + frontendUrl : attr('string'), + webAppUrl : attr('string'), + staticDomain : attr('string'), + cookiePolicy : attr('string'), + cookiePolicyLink : attr('string'), /** * Computed properties diff --git a/app/templates/components/forms/admin/settings/system-form.hbs b/app/templates/components/forms/admin/settings/system-form.hbs index 228a8bcbc5e..ad6d0c49f09 100644 --- a/app/templates/components/forms/admin/settings/system-form.hbs +++ b/app/templates/components/forms/admin/settings/system-form.hbs @@ -33,10 +33,9 @@ {{input type='text' name='tag_line' value=settings.tagline}} - {{forms/admin/settings/system/social-media-token settings=settings}} - - + + {{forms/admin/settings/system/captcha-form settings=settings}} {{forms/admin/settings/system/storage-option settings=settings}} diff --git a/app/templates/components/forms/admin/settings/system/captcha-form.hbs b/app/templates/components/forms/admin/settings/system/captcha-form.hbs new file mode 100644 index 00000000000..7af370f9795 --- /dev/null +++ b/app/templates/components/forms/admin/settings/system/captcha-form.hbs @@ -0,0 +1,36 @@ +

+ {{t 'Captcha Options'}} +
+ {{t 'Captcha settings for sensitive actions in app.'}} +
+

+
+ + {{ui-checkbox class='toggle' checked=settings.isGoogleRecaptchaEnabled onChange=(action (mut settings.isGoogleRecaptchaEnabled))}} +
+{{#if settings.isGoogleRecaptchaEnabled}} +

+ {{t 'Google reCaptcha'}} +
+ {{t 'See'}} + + {{t 'here'}} + + {{t 'on how to obtain these keys.'}} +
+

+
+ + {{input type='text' name='google_recaptcha_sitekey' value=settings.googleRecaptchaSitekey}} +
+
+ + {{input type='text' name='google_recaptcha_secretkey' value=settings.googleRecaptchaSecretkey}} +
+{{/if}} \ No newline at end of file diff --git a/tests/integration/components/forms/admin/settings/system/captcha-form-test.js b/tests/integration/components/forms/admin/settings/system/captcha-form-test.js new file mode 100644 index 00000000000..5723e028eb5 --- /dev/null +++ b/tests/integration/components/forms/admin/settings/system/captcha-form-test.js @@ -0,0 +1,16 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import hbs from 'htmlbars-inline-precompile'; + +module('Integration | Component | forms/admin/settings/system/captcha-form', function(hooks) { + setupRenderingTest(hooks); + + test('it renders', async function(assert) { + + await render(hbs`{{forms/admin/settings/system/captcha-form}}`); + + assert.ok(this.element.innerHTML.trim().includes('Captcha Options')); + + }); +}); From d0289785bb5bf623af27e33299305bd4b4ee3c25 Mon Sep 17 00:00:00 2001 From: kushthedude Date: Mon, 1 Jul 2019 23:08:02 +0530 Subject: [PATCH 2/2] Validation Rules Addition --- .../forms/admin/settings/system-form.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/components/forms/admin/settings/system-form.js b/app/components/forms/admin/settings/system-form.js index e61ed3297d8..cf0b6f1e382 100644 --- a/app/components/forms/admin/settings/system-form.js +++ b/app/components/forms/admin/settings/system-form.js @@ -99,6 +99,26 @@ export default Component.extend(FormMixin, { ] }, + googlereCAPTCHAsitekey: { + identifier : 'google_recaptcha_sitekey', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the reCAPTCHA site key') + } + ] + }, + + googlereCAPTCHAsecretkey: { + identifier : 'google_recaptcha_secretkey', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the reCAPTCHA secret key') + } + ] + }, + emailFrom: { identifier : 'email_from', rules : [