Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
ebaabcd
Updates .env.example
wetoolaguer Jun 24, 2019
f6b3bac
Install and configure devise for sign up without password
danieldraper Jun 11, 2019
b1d60d5
Rewords password edit form
wetoolaguer Jun 24, 2019
afec299
Adds dashboard page
wetoolaguer Jun 24, 2019
fab9763
Adds temporary notice flash
wetoolaguer Jun 24, 2019
7781f67
Redirects to dashboard after setting the password
wetoolaguer Jun 24, 2019
7f9ff21
Adds a new homepage with a registration form
wetoolaguer Jun 24, 2019
bc0aa16
Adds user registration test
wetoolaguer Jun 24, 2019
381d880
Setups factory_bot
wetoolaguer Jun 25, 2019
4dbd0b7
Adds user confirmation tests
wetoolaguer Jun 25, 2019
48aebcb
Fixes failing specs
wetoolaguer Jun 25, 2019
b8240e1
Sets SecretsController as authenticated
wetoolaguer Jun 25, 2019
c7298e8
Removes unneeded require_validated_email
wetoolaguer Jun 25, 2019
d901ff9
Fixes sending secret spec
wetoolaguer Jun 25, 2019
8e33fd6
Fixes closed system spec
wetoolaguer Jun 25, 2019
98f4ed1
Removes unneeded auth_tokens_controller
wetoolaguer Jun 25, 2019
e96ef93
Fixes failing specs
wetoolaguer Jun 25, 2019
73497ca
Removes unneeded AuthTokenService
wetoolaguer Jun 25, 2019
05a9fed
Removes unneeded AuthTokenService spec
wetoolaguer Jun 25, 2019
cf5a752
Removes unneeded AuthToken notify method
wetoolaguer Jun 25, 2019
918655c
Removes unneeded auth_tokens view
wetoolaguer Jun 25, 2019
f798441
Routing fixes
wetoolaguer Jun 25, 2019
1af295a
Adds devise layout
wetoolaguer Jun 25, 2019
7d7d679
Adds devise layout
wetoolaguer Jun 25, 2019
c05d7a4
Improves devise forms styles
wetoolaguer Jun 25, 2019
ad9e315
Removes unneeded application controller methods
wetoolaguer Jun 25, 2019
a42d77b
Adds recaptcha validation in registrations controller
wetoolaguer Jun 26, 2019
f3daffc
Adjusts registration via google account
wetoolaguer Jun 26, 2019
355a47e
Improves Google Auth flow
wetoolaguer Jun 26, 2019
8e60a67
Adds tests for oauth flow
wetoolaguer Jun 26, 2019
bb3f522
Adds more methods to authorised_email_service
wetoolaguer Jun 26, 2019
f96f169
Cleanups constant based authorisation values
wetoolaguer Jun 26, 2019
0f42fad
Prevents user from registering when email is aunauthorised
wetoolaguer Jun 26, 2019
e138ecd
Test cleanups
wetoolaguer Jun 26, 2019
f2da7dd
Prevents user from registering via oauth if domain is not authorised
wetoolaguer Jun 26, 2019
ae61e6d
User feedback improvements
wetoolaguer Jun 26, 2019
7ef0b9d
Adds recaptcha tags in registration form
wetoolaguer Jun 26, 2019
a39188f
Moves authorised email validation to model
wetoolaguer Jun 26, 2019
b5b98aa
Form style fixes
wetoolaguer Jun 26, 2019
8dd7657
Refactors to only use 1 type of flash
wetoolaguer Jun 26, 2019
d49790b
Fixes header links
wetoolaguer Jun 27, 2019
2a8989e
Fixes footer links
wetoolaguer Jun 27, 2019
0d4d229
Reruns bundle install with new ruby version
wetoolaguer Jun 27, 2019
768ddd3
Cleanups
wetoolaguer Jun 27, 2019
168efe8
Sets home to dashboard page
wetoolaguer Jun 27, 2019
df2afd6
Adds user-secret relationship
wetoolaguer Jun 27, 2019
ef1a068
Adds secret_item component
wetoolaguer Jun 27, 2019
e4a5e44
Styles secret-item
wetoolaguer Jun 27, 2019
dc8f0b3
Styles dashboard
wetoolaguer Jun 27, 2019
586b5c7
Adds a way to toggle notes
wetoolaguer Jun 27, 2019
607a1f6
Adds locked/unlocked icons
wetoolaguer Jun 27, 2019
23dd3e5
Shows time in local format
wetoolaguer Jun 27, 2019
d80ee39
Redirects to new_secret_path when user has no secret
wetoolaguer Jun 27, 2019
e7ed36f
Fixes failing tests
wetoolaguer Jun 27, 2019
39991dc
Adds tests for dashboard
wetoolaguer Jun 28, 2019
45c68d8
Cleanups
wetoolaguer Jun 28, 2019
8395145
Adds a link to registration when the user views the secret
wetoolaguer Jun 28, 2019
1a44ea8
Adds resend secret function in dashboard
wetoolaguer Jun 28, 2019
7773a01
Adds test for resend function
wetoolaguer Jun 28, 2019
62be7e7
Responsiveness fixes
wetoolaguer Jun 28, 2019
7793b0d
Style fixes
wetoolaguer Jun 28, 2019
3d0f499
Merge pull request #39 from exec-io/fix/env-sample
wetoolaguer Jun 30, 2019
c068abd
Converts resend to send another secret
wetoolaguer Jul 1, 2019
4b36011
Styles send another button
wetoolaguer Jul 1, 2019
f62664c
Adds extend function
wetoolaguer Jul 1, 2019
9e61da3
Adds tests for extending secret
wetoolaguer Jul 1, 2019
97f3365
Adds test for sending another secret
wetoolaguer Jul 1, 2019
42c1afd
User feedback improvements for expired secret
wetoolaguer Jul 1, 2019
415a71f
Test fixes and cleanups
wetoolaguer Jul 1, 2019
6b7f127
Adds seed for different secret states
wetoolaguer Jul 1, 2019
3d82d75
Replaces Time.now with Time.current calls
wetoolaguer Jul 1, 2019
3ad48d8
Adds email reference on expired error
wetoolaguer Jul 1, 2019
57a9e24
Improves registration handling for one-off users
wetoolaguer Jul 1, 2019
c4fac79
Improves handling of one-off users in oaauth controller
wetoolaguer Jul 1, 2019
ab34f08
Adds tests for oauth one-off user handling
wetoolaguer Jul 1, 2019
8d920be
Limits extending of secret to just once
wetoolaguer Jul 2, 2019
c3eeeb4
Cleanups
wetoolaguer Jul 2, 2019
9590173
Removes dashboard time format from helper to i18n
wetoolaguer Jul 4, 2019
641c9ba
Merge pull request #40 from exec-io/feature/register-user
wetoolaguer Jul 4, 2019
5d069b9
Merge pull request #42 from exec-io/feature/dashboard
wetoolaguer Jul 4, 2019
72776ba
Merge pull request #43 from exec-io/feature/recipient-registration-link
wetoolaguer Jul 4, 2019
a880487
Merge pull request #45 from exec-io/feature/one-off-user-handling
wetoolaguer Jul 4, 2019
4243536
Merge branch 'develop' into feature/resend-secret
wetoolaguer Jul 4, 2019
569cdfd
Renames method to extend_expiry!
wetoolaguer Jul 4, 2019
2a1a69a
Enables ujs
wetoolaguer Jul 4, 2019
b7f6212
Moves secret extend_expiry action to a separate controller
wetoolaguer Jul 4, 2019
df8adec
Setups devise-two-factor
wetoolaguer Jul 2, 2019
ebb6498
Adds supporting gems to 2FA process
wetoolaguer Jul 2, 2019
7ba6841
Adds TwoFactorService
wetoolaguer Jul 2, 2019
149db65
Adds 2FA form an controller handling
wetoolaguer Jul 2, 2019
0877fa9
Adds 2FA fields toggling
wetoolaguer Jul 3, 2019
3f86e59
Styles two-factor form / fields
wetoolaguer Jul 3, 2019
79c1dba
Adds navigation to two-factor page
wetoolaguer Jul 3, 2019
17a34bf
Fixes autocomplete off
wetoolaguer Jul 3, 2019
8414210
Improves user feedback when authentication error happens
wetoolaguer Jul 3, 2019
2b8f510
Adds otp_attempt to log filter
wetoolaguer Jul 3, 2019
4fa690b
Enables logging in with OTP
wetoolaguer Jul 3, 2019
199ea4d
Allows user to login with 2FA
wetoolaguer Jul 3, 2019
9f337ac
Adds TwoFactorService tests
wetoolaguer Jul 3, 2019
c93752b
Flash fixes
wetoolaguer Jul 3, 2019
4cf7a32
Fixes setup for js:true when running on Poltergeist
wetoolaguer Jul 4, 2019
ddf3d02
Adds tests for two-factor auth setup
wetoolaguer Jul 4, 2019
d6daf84
Adds tests for user session
wetoolaguer Jul 4, 2019
a3f397d
Cleanups to two-factor actions
wetoolaguer Jul 4, 2019
a721295
Adds 2FA_KEY in .env.example
wetoolaguer Jul 4, 2019
48b075b
Uses the redirect_uri declared in env for oauth
wetoolaguer Jul 5, 2019
613064b
Uses base_uri instead of full uri
wetoolaguer Jul 5, 2019
b1ba1f5
Adds dashboard link to account dropdown
wetoolaguer Jul 5, 2019
9186baa
initially hides enable-otp-fields to prevent flicker
wetoolaguer Jul 5, 2019
443257f
Test fixes
wetoolaguer Jul 5, 2019
d2ec7a5
Fixes favicon link
wetoolaguer Jul 5, 2019
e277a12
Merge pull request #44 from exec-io/feature/resend-secret
wetoolaguer Jul 7, 2019
e5ca405
Merge branch 'develop' into feature/2FA
wetoolaguer Jul 8, 2019
0f0e0a5
Adds a separate controller/page for user setup
wetoolaguer Jul 4, 2019
6a2015b
Adds two-factor fields in user setup
wetoolaguer Jul 4, 2019
eeb56ce
Prevents user from seeing current password if it is unset
wetoolaguer Jul 4, 2019
62353f9
Adds user setup service
wetoolaguer Jul 5, 2019
2ef2073
Integrates setup service with controller
wetoolaguer Jul 5, 2019
96ce602
Changes confirmation redirect path
wetoolaguer Jul 8, 2019
37552ec
Fixes two-factor-field's reusability
wetoolaguer Jul 8, 2019
407d9f5
Fixes failing specs
wetoolaguer Jul 8, 2019
83131df
Adds UserSetupService spec
wetoolaguer Jul 8, 2019
12b5a54
Adds test for setting of 2FA on confirmation
wetoolaguer Jul 8, 2019
95f93ee
Cleanups and adds more tests
wetoolaguer Jul 8, 2019
6d579fc
Fixes handling of failed credential upgrade
wetoolaguer Jul 8, 2019
8c2d8ad
Adds ability to copy secret link instead of sending an email
wetoolaguer Jul 8, 2019
9494cee
Adds copy service
wetoolaguer Jul 9, 2019
b673159
Styles copy page
wetoolaguer Jul 9, 2019
6ee437f
Adds email fields toggling for secret form
wetoolaguer Jul 9, 2019
59449df
Fixes view for secrets that are sent manually
wetoolaguer Jul 9, 2019
225275d
Adds test to CopySecretService
wetoolaguer Jul 9, 2019
573d0ce
Adds test for sending a secret without email
wetoolaguer Jul 9, 2019
c5ab3ab
Code cleandups
wetoolaguer Jul 9, 2019
e8765b2
Adds settings layout
wetoolaguer Jul 9, 2019
3e3454f
Styles fixes
wetoolaguer Jul 10, 2019
75b9399
HIdes unimplemented pages
wetoolaguer Jul 10, 2019
d4d7603
Adds test
wetoolaguer Jul 10, 2019
bcb3d7e
Code cleanups
wetoolaguer Jul 10, 2019
5fb4fc5
Adds email template on settings page
wetoolaguer Jul 10, 2019
4064bef
Adds user settings
wetoolaguer Jul 10, 2019
87f3f11
Configures trix editor
wetoolaguer Jul 10, 2019
5373dbf
Overrides send_secret_email_template when nil
wetoolaguer Jul 10, 2019
f4d7b5b
Adds view builder
wetoolaguer Jul 10, 2019
f3a1da2
Moves out sending of email from secret service
wetoolaguer Jul 10, 2019
9dde02e
Handles update of email template
wetoolaguer Jul 10, 2019
fd1d577
Handles text only emails
wetoolaguer Jul 10, 2019
f276281
Adds email preview
wetoolaguer Jul 10, 2019
5097d33
Code cleanups
wetoolaguer Jul 10, 2019
ef6f827
Adds feature test for updating email template
wetoolaguer Jul 11, 2019
f63c096
Adds tests to lib files
wetoolaguer Jul 11, 2019
f56a30c
Adds test for settings creation
wetoolaguer Jul 11, 2019
eccf1ce
Test fixes
wetoolaguer Jul 11, 2019
de9bcf3
Merge pull request #46 from exec-io/feature/2FA
wetoolaguer Jul 14, 2019
37d24d5
Merge pull request #47 from exec-io/feature/2FA-on-reg
wetoolaguer Jul 14, 2019
d1f3e01
Merge pull request #48 from exec-io/feature/copy-secret
wetoolaguer Jul 14, 2019
93e446c
Merge pull request #49 from exec-io/feature/settings-page
wetoolaguer Jul 14, 2019
eab9c98
Merge branch 'develop' into feature/email-template
wetoolaguer Jul 15, 2019
611b78a
Code cleanups/improvements
wetoolaguer Jul 15, 2019
403779b
Merge pull request #50 from exec-io/feature/email-template
mikel Jul 16, 2019
b481c49
Configures stripe gem
wetoolaguer Jul 15, 2019
4471f63
Updates oauth and stripe gem
wetoolaguer Jul 15, 2019
cced54b
Adds stripe form
wetoolaguer Jul 15, 2019
4e71b65
Adds subscription service
wetoolaguer Jul 15, 2019
b48a157
Adds keys to env.example
wetoolaguer Jul 25, 2019
d05df95
Adds subscription
wetoolaguer Jul 25, 2019
f34fcf5
Integrates subscription creation
wetoolaguer Jul 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
TOPSEKRIT_AUTHORISATION_SETTING='open'
TOPSEKRIT_AUTHORISED_DOMAIN='reinteractive.net'
GOOGLE_OAUTH_CALLBACK_PATH='/auth/google_oauth2/callback'
GOOGLE_CLIENT_ID='<client_id>'
GOOGLE_CLIENT_SECRET='<client_secret>'
GOOGLE_OAUTH_CLIENT_ID='<client_id>'
GOOGLE_OAUTH_CLIENT_SECRET='<client_secret>'
BASE_URL='http://localhost:3000'
TOPSEKRIT_EXPIRY_DAYS='14'
TOPSEKRIT_EXPIRY_DAYS='14'
RECAPTCHA_SITE_KEY='<site_key>'
RECAPTCHA_SECRET_KEY='<secret_key>'
2FA_KEY='<two_factor_encryption_key>'
STRIPE_PUBLISHABLE_KEY='<stripe_publishable_key>'
STRIPE_SECRET_KEY='<stripe_secret_key>'
STRIPE_SUBSCRIPTION_PLAN_ID='<stripe_subscription_plan_id>'
19 changes: 19 additions & 0 deletions Architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Architecture
* Last update: July 25, 2019
* This is a living document. Please update this whenever you can.
* This is not 100% complete, the intention is to give you an overview of the system

## Models
### User
```
has_many :subscriptions
```

### Subscription
```
code: string
status: integer # enum

cached_metadata: json
cached_transaction_details: json
```
11 changes: 10 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ gem "bugsnag"
gem "okcomputer"
gem "skylight"
gem 'rails_12factor', group: :production
gem "devise"
gem "devise-two-factor"
gem "rqrcode-rails3"
gem "mini_magick"
gem "local_time"
gem "trix"
gem "stripe"

gem 'sdoc', '~> 0.4.0', group: :doc

Expand All @@ -41,14 +48,16 @@ group :test do
gem "capybara"
gem "poltergeist"
gem "rspec-rails"
gem "factory_girl_rails"
gem "factory_bot_rails"
gem "database_cleaner"
gem "faker"
gem "launchy"
gem "show_me_the_cookies", "~> 3.1.0"
gem "timecop"
end

group :development, :test do
gem "byebug"
gem "dotenv-rails"
gem 'pry'
end
75 changes: 62 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ GEM
encryptor (~> 3.0.0)
autoprefixer-rails (6.7.7.1)
execjs
bcrypt (3.1.11)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
Expand All @@ -66,11 +67,25 @@ GEM
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
chunky_png (1.3.11)
cliver (0.3.2)
coderay (1.1.1)
concurrent-ruby (1.0.5)
connection_pool (2.2.2)
database_cleaner (1.5.3)
debug_inspector (0.0.2)
devise (4.4.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
responders
warden (~> 1.2.3)
devise-two-factor (3.0.3)
activesupport (< 5.3)
attr_encrypted (>= 1.3, < 4, != 2)
devise (~> 4.0)
railties (< 5.3)
rotp (~> 2.0)
diff-lcs (1.3)
dotenv (2.2.0)
dotenv-rails (2.2.0)
Expand All @@ -81,14 +96,14 @@ GEM
encryptor (3.0.0)
erubis (2.7.0)
execjs (2.7.0)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.8.0)
factory_girl (~> 4.8.0)
railties (>= 3.0.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.2)
factory_bot (~> 5.0.2)
railties (>= 4.2.0)
faker (1.7.3)
i18n (~> 0.5)
faraday (0.11.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
globalid (0.3.7)
activesupport (>= 4.1.0)
Expand All @@ -106,6 +121,7 @@ GEM
kgio (2.11.0)
launchy (2.4.3)
addressable (~> 2.3)
local_time (2.1.0)
logstash-event (1.2.02)
logstasher (0.6.5)
logstash-event (~> 1.2.0)
Expand All @@ -114,19 +130,23 @@ GEM
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.9.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_magick (4.9.3)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
multipart-post (2.1.1)
net-http-persistent (3.0.1)
connection_pool (~> 2.2)
nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
oauth2 (1.4.1)
faraday (>= 0.8, < 0.16.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
Expand All @@ -142,6 +162,7 @@ GEM
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
orm_adapter (0.5.0)
parser (2.4.0.0)
ast (~> 2.2)
pg (0.20.0)
Expand All @@ -152,10 +173,13 @@ GEM
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
powerpack (0.1.1)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (2.0.5)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.6.5)
rack (1.6.11)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.8)
Expand Down Expand Up @@ -194,6 +218,14 @@ GEM
recaptcha (4.10.0)
json
request_store (1.3.2)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
rotp (2.1.2)
rqrcode (0.10.1)
chunky_png (~> 1.0)
rqrcode-rails3 (0.1.7)
rqrcode (>= 0.4.2)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
Expand Down Expand Up @@ -242,9 +274,15 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
stripe (4.21.2)
faraday (~> 0.13)
net-http-persistent (~> 3.0)
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.7)
timecop (0.9.1)
trix (0.11.1)
rails (> 4.1, < 5.2)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uglifier (3.2.0)
Expand All @@ -256,6 +294,8 @@ GEM
unicorn-rails (2.2.1)
rack
unicorn
warden (1.2.7)
rack (>= 1.0)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
Expand All @@ -280,30 +320,39 @@ DEPENDENCIES
capybara
carrierwave
database_cleaner
devise
devise-two-factor
dotenv-rails
email_validator
factory_girl_rails
factory_bot_rails
faker
jbuilder (~> 2.0)
jquery-rails
launchy
local_time
logstasher (~> 0.6.5)
mini_magick
okcomputer
omniauth-google-oauth2
pg
pickadate-rails
poltergeist
pry
quiet_assets
rails (~> 4.2.8)
rails_12factor
recaptcha
rqrcode-rails3
rspec-rails
rubocop
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
show_me_the_cookies (~> 3.1.0)
simple_form
skylight
stripe
timecop
trix
uglifier (>= 1.3.0)
unicorn
unicorn-rails
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,3 @@ Some helpful commands:

heroku restart -a rei-secretlink-production
heroku logs --tail -a rei-secretlink-production

Binary file added app/assets/images/apple-app-store.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/google-play-store.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions app/assets/images/locked-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions app/assets/images/unlocked-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//= require jquery
//= require jquery_ujs
//= require pickadate/picker
//= require pickadate/picker.date
//= require bootstrap-sprockets
//= require topsekrit
//= require ui-functions
//= require local-time
//= require trix

// Components
//= require components/secret-item
//= require components/two-factor-fields
//= require components/new-secret-form
//= require components/stripe-form
32 changes: 32 additions & 0 deletions app/assets/javascripts/components/new-secret-form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
$(function() {
function NewSecretForm(rootDom) {
this.$root = $(rootDom);
this.$noEmailToggle = this.$root.find('.no-email-toggle');
this.$fromEmailField = this.$root.find('.secret_from_email');
this.$toEmailField = this.$root.find('.secret_to_email');
this.$toEmailInput = this.$root.find("input[name='secret[to_email]']")
this.init();
}

NewSecretForm.prototype.init = function () {
this.$noEmailToggle.change(function() {
this.toggleEmailFields(!this.withoutEmail());
}.bind(this));
}

NewSecretForm.prototype.toggleEmailFields = function (showField) {
this.$fromEmailField.toggle(showField);
this.$toEmailField.toggle(showField);
this.$toEmailInput.val('');
}

NewSecretForm.prototype.withoutEmail = function () {
return this.$noEmailToggle.is(':checked');
}

//Intialization code
const $newSecretForm = $(this).find(".js-new-secret-form");
$newSecretForm.each(function () {
new NewSecretForm(this)
})
});
Loading