Skip to content

Commit

Permalink
google default login (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
adnjoo authored Nov 4, 2024
1 parent 6fd87f5 commit 0ee0780
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 93 deletions.
10 changes: 7 additions & 3 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
class Users::RegistrationsController < Devise::RegistrationsController
protected

# Override the `update_resource` method to handle profile picture removal
# Override the `update_resource` method to handle profile picture removal and password validation
def update_resource(resource, params)
if params[:remove_profile_picture] == "1"
resource.profile_picture.purge
end

# Call the original update method with the remaining parameters
super
# Skip password validation if password fields are blank
if params[:password].blank? && params[:password_confirmation].blank?
resource.update_without_password(params.except(:current_password))
else
super
end
end
end
26 changes: 2 additions & 24 deletions app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,37 +53,15 @@
</div>
</div>

<!-- Password Fields -->
<div class="flex flex-col">
<%= f.label :password, class: "text-lg font-semibold uppercase tracking-wide text-black" %>
<i class="text-sm text-gray-700">(leave blank if you don't want to change it)</i>
<%= f.password_field :password, autocomplete: "new-password", class: "border-2 border-black px-4 py-2 bg-white text-black focus:outline-none focus:border-gray-700" %>
<% if @minimum_password_length %>
<em class="text-sm text-gray-600"><%= @minimum_password_length %> characters minimum</em>
<% end %>
</div>

<div class="flex flex-col">
<%= f.label :password_confirmation, class: "text-lg font-semibold uppercase tracking-wide text-black" %>
<%= f.password_field :password_confirmation, autocomplete: "new-password", class: "border-2 border-black px-4 py-2 bg-white text-black focus:outline-none focus:border-gray-700" %>
</div>

<div class="flex flex-col">
<%= f.label :current_password, class: "text-lg font-semibold uppercase tracking-wide text-black" %>
<i class="text-sm text-gray-700">(we need your current password to confirm your changes)</i>
<%= f.password_field :current_password, autocomplete: "current-password", class: "border-2 border-black px-4 py-2 bg-white text-black focus:outline-none focus:border-gray-700" %>
</div>

<!-- Submit Button -->
<div>
<%= f.submit "Update", class: "bg-black text-white px-6 py-2 uppercase font-bold tracking-wider hover:bg-gray-800 transition-all cursor-pointer" %>
</div>
<% end %>

<h3 class="text-2xl font-bold uppercase tracking-wide text-black mt-10">Cancel my account</h3>
<div class="mt-4 text-black">
Unhappy?
Email us at <%= link_to DEFAULT_TO_EMAIL, "mailto:#{DEFAULT_TO_EMAIL}?subject=Cancel Account", class: "text-black underline" %> to cancel your account.
<h3 class="text-2xl font-bold text-black mt-10">Cancel my account</h3>
<%= button_to "Cancel my account", registration_path(resource_name), class: "bg-red-600 text-white mt-4 px-4 py-2 uppercase font-bold hover:bg-red-800 transition-all cursor-pointer", data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %>
</div>

<%= link_to "Back", :back, class: "text-black underline hover:text-gray-800 mt-6 inline-block" %>
Expand Down
21 changes: 0 additions & 21 deletions app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
<div class="!max-w-lg my-container animate-in">
<h2 class="text-4xl font-extrabold text-black mb-6">Sign up</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { class: "bg-white p-8 border-2 border-black shadow-md" }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field mb-4">
<%= f.label :email, class: "block text-lg font-bold text-black" %>
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: "mt-1 block w-full p-2 border-2 border-black" %>
</div>
<div class="field mb-4">
<%= f.label :password, class: "block text-lg font-bold text-black" %>
<% if @minimum_password_length %>
<em class="text-gray-700">(<%= @minimum_password_length %> characters minimum)</em>
<% end %>
<%= f.password_field :password, autocomplete: "new-password", class: "mt-1 block w-full p-2 border-2 border-black" %>
</div>
<div class="field mb-4">
<%= f.label :password_confirmation, class: "block text-lg font-bold text-black" %>
<%= f.password_field :password_confirmation, autocomplete: "new-password", class: "mt-1 block w-full p-2 border-2 border-black" %>
</div>
<div class="actions">
<%= f.submit "Sign up", class: "bg-black text-white px-4 py-2 border-2 border-black hover:bg-gray-800 transition duration-300" %>
</div>
<% end %>
<br>
<%= render "devise/shared/links" %>
</div>
20 changes: 1 addition & 19 deletions app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
<div class="!max-w-lg my-container animate-in">
<h2 class="text-4xl font-extrabold text-black mb-6">Log in</h2>
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "bg-white p-8 border-2 border-black shadow-md" }) do |f| %>
<div class="field mb-4">
<%= f.label :email, class: "block text-lg font-bold text-black" %>
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: "mt-1 block w-full p-2 border-2 border-black" %>
</div>
<div class="field mb-4">
<%= f.label :password, class: "block text-lg font-bold text-black" %>
<%= f.password_field :password, autocomplete: "current-password", class: "mt-1 block w-full p-2 border-2 border-black" %>
</div>
<% if devise_mapping.rememberable? %>
<div class="field mb-4">
<%= f.check_box :remember_me, class: "mr-2" %>
<%= f.label :remember_me, class: "inline-block text-lg font-bold text-black" %>
</div>
<% end %>
<div class="actions">
<%= f.submit "Log in", class: "bg-black text-white px-4 py-2 border-2 border-black hover:bg-gray-800 transition duration-300" %>
</div>
<% end %>

<br>
<%= render "devise/shared/links" %>
</div>
36 changes: 13 additions & 23 deletions app/views/devise/shared/_links.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name), class: "text-black hover:text-gray-700 font-bold" %><br />
<% end %>


<%#- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%#= link_to "Sign up", new_registration_path(resource_name), class: "text-black hover:text-gray-700 font-bold" %><br />
<%# end %>

<%= link_to "Join the Waitlist", WAITLIST_LINK, class: "hidden text-black hover:text-gray-700 font-bold" %><br />

<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name), class: "text-black hover:text-gray-700 font-bold" %><br />
<% end %>

<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name), class: "text-black hover:text-gray-700 font-bold" %><br />
<% end %>

<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name), class: "text-black hover:text-gray-700 font-bold" %><br />
<% end %>

<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= button_to omniauth_authorize_path(resource_name, provider),
Expand All @@ -35,3 +12,16 @@
<% end %>
<% end %>

<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name), class: "hidden text-black hover:text-gray-700 font-bold" %><br />
<% end %>

<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name), class: "text-black hover:text-gray-700 font-bold" %><br />
<% end %>

<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name), class: "text-black hover:text-gray-700 font-bold" %><br />
<% end %>


2 changes: 1 addition & 1 deletion app/views/posts/introducing-dueltasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ By using the <a href="/blog/loss-aversion" target="_blank">science of loss avers

## Get Started

<a href="https://forms.gle/6sFw9P3nqfKd575F7" target="_blank">Sign up for the DuelTasks waitlist</a> and we'll let you know soon when it's available! πŸ•
<a href="/users/sign_in" target="_blank">Sign up for DuelTasks πŸ•

---

Expand Down
2 changes: 1 addition & 1 deletion app/views/posts/loss-aversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ The curve shows that losses feel more painful than the equivalent amount of gain

## Get Started

<a href="https://forms.gle/6sFw9P3nqfKd575F7" target="_blank">Sign up for the DuelTasks waitlist</a> and we'll let you know soon when it's available! πŸ•
<a href="/users/sign_in" target="_blank">Sign up for DuelTasks πŸ•
2 changes: 1 addition & 1 deletion app/views/posts/multiplayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ We know that accountability is a huge factor in completing tasks. With Multiplay

## Get Started

<a href="https://forms.gle/6sFw9P3nqfKd575F7" target="_blank">Sign up for the DuelTasks waitlist</a> and we'll let you know soon when it's available! πŸ•
<a href="/users/sign_in" target="_blank">Sign up for DuelTasks πŸ•

0 comments on commit 0ee0780

Please sign in to comment.