This commit is contained in:
neo773
2025-04-12 03:39:01 +05:30
parent 859016efbf
commit 098ae2d348
3 changed files with 15 additions and 20 deletions

View File

@@ -54,27 +54,27 @@ class RegistrationsController < ApplicationController
redirect_to new_registration_path, alert: t("registrations.create.invalid_invite_code")
end
end
def validate_password_requirements
password = user_params[:password]
return if password.blank? # Let Rails built-in validations handle blank passwords
if password.length < 8
@user.errors.add(:password, "must be at least 8 characters")
end
unless password.match?(/[A-Z]/) && password.match?(/[a-z]/)
@user.errors.add(:password, "must include both uppercase and lowercase letters")
end
unless password.match?(/\d/)
@user.errors.add(:password, "must include at least one number")
end
unless password.match?(/[!@#$%^&*(),.?":{}|<>]/)
@user.errors.add(:password, "must include at least one special character")
end
if @user.errors.present?
render :new, status: :unprocessable_entity
end

View File

@@ -5,7 +5,6 @@ export default class extends Controller {
static targets = ["input", "showIcon", "hideIcon"];
connect() {
// Initially hide the eye-off icon
this.hideIconTarget.classList.add("hidden");
}

View File

@@ -6,26 +6,22 @@
<div class="flex justify-center mt-2 md:mb-6">
<%= image_tag "logo-color.png", class: "w-16 mb-6" %>
</div>
<div class="space-y-2">
<h2 class="text-3xl font-medium text-primary text-center">
<%= content_for?(:header_title) ? yield(:header_title).html_safe : t(".your_account") %>
</h2>
<div class="space-y-3 md:hidden w-full my-4">
<div class="bg-surface-inset rounded-lg p-1 flex">
<%= link_to new_session_path,
<div class="bg-surface-inset rounded-lg p-1 flex">
<%= link_to new_session_path,
class: "w-1/2 px-2 py-1 rounded-md text-sm text-center font-medium #{current_page?(new_session_path) ? 'bg-surface shadow-sm text-primary' : 'text-secondary'}" do %>
<%= t("layouts.auth.sign_in") %>
<% end %>
<%= link_to new_registration_path,
<%= t("layouts.auth.sign_in") %>
<% end %>
<%= link_to new_registration_path,
class: "w-1/2 px-2 py-1 rounded-md text-sm text-center font-medium #{!current_page?(new_session_path) ? 'bg-surface shadow-sm text-primary' : 'text-secondary'}" do %>
<%= t("layouts.auth.sign_up") %>
<% end %>
</div>
</div>
<%= t("layouts.auth.sign_up") %>
<% end %>
</div>
</div>
<% if controller_name == "sessions" %>
<p class="text-sm text-center hidden md:block">
<%= tag.span t(".no_account"), class: "text-secondary" %> <%= link_to t(".sign_up"), new_registration_path, class: "font-medium text-primary hover:underline transition" %>