Skip to content

Commit

Permalink
feat: add user edit page
Browse files Browse the repository at this point in the history
  • Loading branch information
stufro committed Oct 15, 2022
1 parent 5764937 commit 2ddcaf9
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 60 deletions.
9 changes: 8 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require:
require:
- rubocop-rails
- rubocop-rspec

Expand All @@ -18,4 +18,11 @@ Style/StringLiterals:
Style/Documentation:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
RSpec/ExampleLength:
Enabled: false
RSpec/SubjectStub:
Exclude:
- spec/controllers/application_controller_spec.rb
RSpec/NamedSubject:
Enabled: false
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- [x] Fix: ensure you can't view other trial sheets
- [x] Add version to footer
- [x] Make favicon
- [ ] Sending emails (email verification, password resets)
- [x] Sending emails (email verification, password resets)
- [x] Pick opensource license
- [x] Make homepage more appealing
- [x] Make sign up/login banner smaller on trial page
Expand Down
7 changes: 4 additions & 3 deletions app/views/devise/mailer/confirmation_instructions.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ p
= @email
| !
p
| You can confirm your account email through the link below. Confirm your email address within 
strong 24 hours 
| to continue using Chordly.
| You can confirm your account email through the link below.
| Confirm your email address within 
strong 24 hours
| to continue using Chordly.
p
= link_to "Confirm my account", confirmation_url(@resource, confirmation_token: @token)

Expand Down
6 changes: 4 additions & 2 deletions app/views/devise/mailer/reset_password_instructions.html.slim
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
p Hello,

p Someone has requested a link to change your password for the account #{@resource.email}. You can do this through the link below.
p
| Someone has requested a link to change your password for the account #{@resource.email}.
| You can do this through the link below.

p
= link_to "Change my password", edit_password_url(@resource, reset_password_token: @token)
Expand All @@ -12,4 +14,4 @@ p Your password won"t change until you access the link above and create a new on
p
span Thanks,
br
span Chordly
span Chordly
3 changes: 2 additions & 1 deletion app/views/devise/passwords/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
| characters minimum)

.control.has-icons-left
= f.password_field :password, autofocus: true, autocomplete: "new-password", class: "input"
= f.password_field :password, autofocus: true, autocomplete: "new-password",
class: "input"
.span.icon.is-small.is-left
i.fas.fa-key

Expand Down
113 changes: 69 additions & 44 deletions app/views/devise/registrations/edit.html.slim
Original file line number Diff line number Diff line change
@@ -1,44 +1,69 @@
h2
| Edit
= resource_name.to_s.humanize
= form_for(resource, as: resource_name, url: registration_path(resource_name),
html: { method: :put }) do |f|
= render "devise/shared/error_messages", resource: resource
.field
= f.label :email
br
= f.email_field :email, autofocus: true, autocomplete: "email"
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
div
| Currently waiting confirmation for:
= resource.unconfirmed_email
.field
= f.label :password
i
| (leave blank if you don"t want to change it)
br
= f.password_field :password, autocomplete: "new-password"
- if @minimum_password_length
br
em
= @minimum_password_length
| characters minimum
.field
= f.label :password_confirmation
br
= f.password_field :password_confirmation, autocomplete: "new-password"
.field
= f.label :current_password
i
| (we need your current password to confirm your changes)
br
= f.password_field :current_password, autocomplete: "current-password"
.actions
= f.submit "Update"
h3
| Cancel my account
p
| Unhappy?
= button_to "Cancel my account", registration_path(resource_name),
data: { confirm: "Are you sure?" }, method: :delete
= link_to "Back", :back
.card
.card-content
h1.title.is-1
| Edit 
= resource_name.to_s.humanize

= form_for(resource, as: resource_name, url: registration_path(resource_name),
html: { method: :put }) do |f|
= render "devise/shared/error_messages", resource: resource

.field
= f.label :email, class: "label"
.control.has-icons-left
= f.email_field :email, autofocus: true, autocomplete: "email", class: "input"
span.icon.is-small.is-left
i.fas.fa-envelope
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
div
| Currently waiting confirmation for:
= resource.unconfirmed_email

.field
= f.label :password, "New Password", class: "has-text-weight-semibold"
i
| (leave blank if you don't want to change it)
= f.password_field :password, autocomplete: "new-password", class: "input"
- if @minimum_password_length
br
em
= @minimum_password_length
| characters minimum

.field
= f.label :password_confirmation, class: "label"
.control.has-icons-left
= f.password_field :password_confirmation, autocomplete: "new-password", class: "input"
span.icon.is-small.is-left
i.fas.fa-key

.field
= f.label :current_password, class: "has-text-weight-semibold"
i
| (we need your current password to confirm your changes)
.control.has-icons-left
= f.password_field :current_password, autocomplete: "current-password", class: "input"
span.icon.is-small.is-left
i.fas.fa-key

.actions.is-flex.is-justify-content-center
= f.submit "Update", class: "button is-primary is-medium",
data: { turbo: false }, style: "width: 100%"

.message.is-danger.mt-5
.message-header
h2.title.is-4.has-text-light Delete account

.message-body
p
| If you wish to delete your account and all the data we store including your chord sheets
| & set lists, click the button below.
b This CANNOT be undone.

= button_to registration_path(resource_name), class: "button is-danger mt-3",
data: { turbo: false, confirm: "Are you sure? You will lose ALL of your saved data" },
method: :delete do
span.icon-text.is-flex-wrap-nowrap
span.icon
i.fas.fa-trash
span Delete my account
2 changes: 1 addition & 1 deletion app/views/layouts/_favicons.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ link rel="icon" type="image/png" sizes="16x16" href="/favicons/favicon-16x16.png
link rel="manifest" href="/manifest.json"
meta name="msapplication-TileColor" content="#80475E"
meta name="msapplication-TileImage" content="/favicons/ms-icon-144x144.png"
meta name="theme-color" content="#80475E"
meta name="theme-color" content="#80475E"
3 changes: 1 addition & 2 deletions app/views/layouts/_navbar.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ nav.navbar.is-primary aria-label="main navigation" role="navigation" data-contro
span.icon
i.fas.fa-coffee
span Buy me a coffee
.navbar-item
span = current_user.email
= link_to current_user.email, edit_user_registration_path, class: "navbar-item"
.navbar-item
.buttons
= button_to destroy_user_session_path, class: "button is-primary", method: :delete do
Expand Down
4 changes: 2 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
config.x.mail_from = %(Chordly <[email protected]>)
config.action_mailer.default_url_options = { host: "https://chordly.co.uk", port: 443 }
config.action_mailer.smtp_settings = {
address: "email-smtp.eu-west-2.amazonaws.com",
address: "email-smtp.eu-west-2.amazonaws.com",
user_name: Rails.application.credentials.dig(:aws, :smtp_username),
password: Rails.application.credentials.dig(:aws, :smtp_password)
password: Rails.application.credentials.dig(:aws, :smtp_password)
}
config.action_mailer.raise_delivery_errors = true
config.action_mailer.asset_host = "https://chordly.co.uk"
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

it "returns nil" do
session[:trial_user_id] = "abcdefg"
expect(subject.authorize(ChordSheet.new(trial_user_id: "abcdefg", trial: true))).to eq nil
expect(subject.authorize(ChordSheet.new(trial_user_id: "abcdefg", trial: true))).to be_nil
end
end

Expand All @@ -35,7 +35,7 @@
let(:user) { instance_double User, :user, id: 1 }

it "returns nil" do
expect(subject.authorize(ChordSheet.new(user_id: 1))).to eq nil
expect(subject.authorize(ChordSheet.new(user_id: 1))).to be_nil
end
end

Expand All @@ -54,4 +54,4 @@
end
end
end
end
end

0 comments on commit 2ddcaf9

Please sign in to comment.