Skip to content

Commit

Permalink
remember signed in user session
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBTurchyn committed Jul 27, 2023
1 parent 658e8a7 commit 1f29e62
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def active_for_authentication?
!deleted_at?
end

def remember_me
true
end

def initials
[first_name.first, last_name.first].join.upcase
end
Expand Down
8 changes: 0 additions & 8 deletions app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
<%= f.label :password, class: 'label' %>
<%= f.password_field :password, autocomplete: 'current-password', class: 'base-input' %>
</div>
<% if devise_mapping.rememberable? %>
<div class="form-control">
<%= f.label :remember_me, class: 'flex items-center cursor-pointer' do %>
<%= f.check_box :remember_me, checked: true, class: 'base-checkbox' %>
<span class="label">Remember me</span>
<% end %>
</div>
<% end %>
</div>
<div class="form-control">
<%= f.button button_title(title: 'Log In', disabled_with: 'Logging In'), class: 'base-button' %>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@

# ==> Configuration for :rememberable
# The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks
config.remember_for = 2.years

# Invalidates all the remember me tokens when the user signs out.
config.expire_all_remember_me_on_sign_out = true
Expand Down

0 comments on commit 1f29e62

Please sign in to comment.