Skip to content

Commit b5c6510

Browse files
committed
fix: solve register issues
1 parent 5089fe6 commit b5c6510

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/models/user.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@ class User < ApplicationRecord
2323

2424
# Validations
2525
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
26-
validates :full_name, length: { maximum: 255 }
26+
validates :full_name, presence: true, length: { maximum: 255 }
2727
validates :role, presence: true, inclusion: { in: Constants::User::ROLES }
2828
validates :timezone, length: { maximum: 100 }
2929
validates :language, length: { maximum: 10 }
30+
validates :password,
31+
length: { minimum: 8, message: 'must be at least 8 characters' },
32+
format: {
33+
with: /\A(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/,
34+
message: 'must contain at least one uppercase letter, one lowercase letter, and one number'
35+
},
36+
if: -> { password.present? }
3037

3138
# Callbacks
3239
before_save :downcase_email

app/modules/authentication/controllers/auth_controller.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ def register
8484
end
8585
rescue ActiveRecord::RecordInvalid => e
8686
render_validation_errors(e)
87-
rescue StandardError => _e
88-
render_error(message: 'Registration failed', code: 'REGISTRATION_ERROR')
8987
end
9088

9189
# Authenticates a user and returns JWT tokens

0 commit comments

Comments
 (0)