Skip to content

Commit

Permalink
Updated devise views
Browse files Browse the repository at this point in the history
  • Loading branch information
dalezak committed Feb 10, 2022
1 parent d091c97 commit ad83463
Show file tree
Hide file tree
Showing 23 changed files with 229 additions and 364 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ end

gem 'devise', '~> 4.8', '>= 4.8.1'

gem "devise_invitable", "~> 2.0"
gem 'devise-i18n'

gem "cancancan", "~> 3.3"

Expand Down
13 changes: 6 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
annotate (2.6.5)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
aws-eventstream (1.2.0)
aws-partitions (1.553.0)
aws-sdk-core (3.126.0)
Expand Down Expand Up @@ -121,9 +121,8 @@ GEM
responders
warden (~> 1.2.3)
devise-bootstrap5 (0.1.3)
devise_invitable (2.0.6)
actionmailer (>= 5.0)
devise (>= 4.6)
devise-i18n (1.10.1)
devise (>= 4.8.0)
digest (3.1.0)
down (5.2.4)
addressable (~> 2.8)
Expand Down Expand Up @@ -335,7 +334,7 @@ DEPENDENCIES
debug
devise (~> 4.8, >= 4.8.1)
devise-bootstrap5 (~> 0.1.3)
devise_invitable (~> 2.0)
devise-i18n
faker (~> 2.19)
fastimage (~> 2.2)
gems
Expand Down
2 changes: 1 addition & 1 deletion app/models/likes/like.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Like < ApplicationRecord
scope :for_gems, ->(gems) { where(gem_id: gems.pluck(:id)) if gems.present? }

def update_user
self.user.update(gem_names: self.user.gems.map{|gem| gem.name})
self.user.update(gem_list: self.user.gems.map{|gem| gem.name})
end

end
16 changes: 2 additions & 14 deletions app/models/users/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,11 @@
# likes_count :integer default("0")
# created_at :datetime not null
# updated_at :datetime not null
# invitation_token :string
# invitation_created_at :datetime
# invitation_sent_at :datetime
# invitation_accepted_at :datetime
# invitation_limit :integer
# invited_by_type :string
# invited_by_id :integer
# invitations_count :integer default("0")
# identities_count :integer default("0")
#
# Indexes
#
# index_users_on_email (email) UNIQUE
# index_users_on_invitation_token (invitation_token) UNIQUE
# index_users_on_invited_by (invited_by_type,invited_by_id)
# index_users_on_invited_by_id (invited_by_id)
# index_users_on_name (name)
# index_users_on_reset_password_token (reset_password_token) UNIQUE
# index_users_on_slug (slug)
Expand All @@ -52,14 +41,13 @@ class User < ApplicationRecord
include ::Imageable
include ImageUploader::Attachment(:image)

# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :invitable, :database_authenticatable, :omniauthable, :registerable, :recoverable, :rememberable, :validatable
devise :database_authenticatable, :omniauthable, :registerable, :recoverable, :rememberable, :validatable

store_attribute :details, :location, :string
store_attribute :details, :homepage_uri, :string
store_attribute :details, :github_uri, :string
store_attribute :details, :twitter_uri, :string
store_attribute :details, :gem_names, :json, default: []
store_attribute :details, :gem_list, :json, default: []

has_many :identities, dependent: :destroy

Expand Down
38 changes: 21 additions & 17 deletions app/views/devise/confirmations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<div class="row">
<div class="col-md-6">
<h2 class="pb-4"><%= t('.resend_confirmation_instructions') %></h2>

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>

<div class="mb-3">
<%= f.label :email, class: "form-label" %>
<%= f.email_field :email, autofocus: true, autocomplete: 'email', value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email), class: 'form-control' %>
<div class="col-sm-10 col-md-8 col-lg-6 col-xl-4 offset-sm-1 offset-md-2 offset-lg-3 offset-xl-4">
<div class="card mb-4">
<div class="card-header">
<h2 class="card-title"><%= t('.resend_confirmation_instructions') %></h2>
</div>

<div class="mb-3">
<%= f.submit t('.resend_confirmation_instructions'), class: 'btn btn-primary' %>
<div class="card-body">
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="mb-3">
<%= f.label :email, class: "form-label" %>
<%= f.email_field :email, autofocus: true, autocomplete: 'email', value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email), class: 'form-control' %>
</div>
<div class="mb-3">
<%= f.submit t('.resend_confirmation_instructions'), class: 'btn btn-primary' %>
</div>
<% end %>
</div>
<% end %>

<%= render "devise/shared/links" %>
</div>
</div>
<div class="card-footer text-muted">
<%= render "devise/shared/links" %>
</div>
</div>
</div>
</div>
55 changes: 28 additions & 27 deletions app/views/devise/passwords/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
<div class="row">
<div class="col-md-6">

<h2 class="pb-4"><%= t('.change_your_password') %></h2>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<%= f.hidden_field :reset_password_token %>

<div class="mb-3">
<%= f.label :password, t('.new_password'), class: 'form-label' %>
<%= f.password_field :password, autofocus: true, class: 'form-control' %>

<% if @minimum_password_length %>
<div class="form-text"><%= t('devise.shared.minimum_password_length', count: @minimum_password_length) %></div>
<% end %>
<div class="col-sm-10 col-md-8 col-lg-6 col-xl-4 offset-sm-1 offset-md-2 offset-lg-3 offset-xl-4">
<div class="card mb-4">
<div class="card-header">
<h2 class="card-title"><%= t('.change_your_password') %></h2>
</div>

<div class="mb-4">
<%= f.label :password_confirmation, t('.confirm_new_password'), class: 'form-label' %>
<%= f.password_field :password_confirmation, autocomplete: 'off', class: 'form-control' %>
<div class="card-body">
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<%= f.hidden_field :reset_password_token %>
<div class="mb-3">
<%= f.label :password, t('.new_password'), class: 'form-label' %>
<%= f.password_field :password, autofocus: true, class: 'form-control' %>
<% if @minimum_password_length %>
<div class="form-text"><%= t('devise.shared.minimum_password_length', count: @minimum_password_length) %></div>
<% end %>
</div>
<div class="mb-4">
<%= f.label :password_confirmation, t('.confirm_new_password'), class: 'form-label' %>
<%= f.password_field :password_confirmation, autocomplete: 'off', class: 'form-control' %>
</div>
<div class="mb-4">
<%= f.submit t('.change_my_password'), class: 'btn btn-primary' %>
</div>
<% end %>
</div>

<div class="mb-4">
<%= f.submit t('.change_my_password'), class: 'btn btn-primary' %>
<div class="card-footer text-muted">
<%= render "devise/shared/links" %>
</div>
<% end %>

<%= render "devise/shared/links" %>
</div>
</div>
</div>
</div>
</div>
38 changes: 21 additions & 17 deletions app/views/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<div class="row">
<div class="col-md-6">
<h2 class="pb-4"><%= t('.forgot_your_password') %></h2>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>

<div class="mb-4">
<%= f.label :email, class: "form-label" %>
<%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
<div class="col-sm-10 col-md-8 col-lg-6 col-xl-4 offset-sm-1 offset-md-2 offset-lg-3 offset-xl-4">
<div class="card mb-4">
<div class="card-header">
<h2 class="card-title"><%= t('.forgot_your_password') %></h2>
</div>

<div class="mb-4">
<%= f.submit t('.send_me_reset_password_instructions'), class: 'btn btn-primary' %>
<div class="card-body">
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="mb-4">
<%= f.label :email, class: "form-label" %>
<%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
</div>
<div class="mb-4">
<%= f.submit t('.send_me_reset_password_instructions'), class: 'btn btn-primary' %>
</div>
<% end %>
</div>
<% end %>

<%= render "devise/shared/links" %>
</div>
</div>
<div class="card-footer text-muted">
<%= render "devise/shared/links" %>
</div>
</div>
</div>
</div>
92 changes: 46 additions & 46 deletions app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
<div class="row">
<div class="col-md-6">
<h2 class="pb-4"><%= t('.title', resource: resource.model_name.human) %></h2>

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

<div class="mb-3">
<%= f.label :email, class: 'form-label' %>
<%= f.email_field :email, autocomplete: 'email', class: 'form-control' %>
<div class="col-sm-10 col-md-8 col-lg-6 col-xl-4 offset-sm-1 offset-md-2 offset-lg-3 offset-xl-4">
<div class="card mb-4">
<div class="card-header">
<h2 class="card-title"><%= t('.title', resource: resource.model_name.human) %></h2>
</div>

<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div><%= t('.currently_waiting_confirmation_for_email', email: resource.unconfirmed_email) %></div>
<% end %>

<div class="mb-3">
<%= f.label :current_password, class: 'form-label' %>
<%= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control' %>

<div class="form-text"><%= t('.we_need_your_current_password_to_confirm_your_changes') %></div>
<div class="card-body">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="mb-3">
<%= f.label :email, class: 'form-label' %>
<%= f.email_field :email, autocomplete: 'email', class: 'form-control' %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div><%= t('.currently_waiting_confirmation_for_email', email: resource.unconfirmed_email) %></div>
<% end %>
<div class="mb-3">
<%= f.label :current_password, class: 'form-label' %>
<%= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control' %>
<div class="form-text"><%= t('.we_need_your_current_password_to_confirm_your_changes') %></div>
</div>
<div class="row mb-4 mt-4">
<h4><%= t('devise.passwords.edit.change_your_password') %></h4>
<div class="form-text mb-3"><%= t('.leave_blank_if_you_don_t_want_to_change_it') %></div>
<div class="col">
<%= f.label :password, t('devise.passwords.edit.new_password'), class: 'form-label' %>
<%= f.password_field :password, autocomplete: 'new-password', class: 'form-control' %>
<% if @minimum_password_length %>
<div class="form-text"><%= t('devise.shared.minimum_password_length', count: @minimum_password_length) %></div>
<% end %>
</div>
<div class="col">
<%= f.label :password_confirmation, t('devise.passwords.edit.confirm_new_password'), class: 'form-label' %>
<%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %>
</div>
</div>
<div class="mb-3 text-end">
<%= f.submit t('.update'), class: 'btn btn-primary' %>
</div>
<% end %>
<p>
<%= link_to t('.cancel_my_account'), registration_path(resource_name), data: { confirm: t('.are_you_sure') }, method: :delete %>.
</p>
</div>

<div class="row mb-4 mt-4">
<h4><%= t('devise.passwords.edit.change_your_password') %></h4>
<div class="form-text mb-3"><%= t('.leave_blank_if_you_don_t_want_to_change_it') %></div>

<div class="col">
<%= f.label :password, t('devise.passwords.edit.new_password'), class: 'form-label' %>
<%= f.password_field :password, autocomplete: 'new-password', class: 'form-control' %>
<% if @minimum_password_length %>
<div class="form-text"><%= t('devise.shared.minimum_password_length', count: @minimum_password_length) %></div>
<% end %>
</div>
<div class="col">
<%= f.label :password_confirmation, t('devise.passwords.edit.confirm_new_password'), class: 'form-label' %>
<%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %>
</div>
<div class="card-footer text-muted">
<%= render "devise/shared/links" %>
</div>

<div class="mb-3">
<%= f.submit t('.update'), class: 'btn btn-primary' %>
</div>
<% end %>

<p>
<%= link_to t('.cancel_my_account'), registration_path(resource_name), data: { confirm: t('.are_you_sure') }, method: :delete %>.
</p>
</div>
</div>
</div>
</div>
</div>
Loading

0 comments on commit ad83463

Please sign in to comment.