mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 03:07:52 +01:00
Increase user full_name max length to 64 characters (#403)
This commit is contained in:
committed by
GitHub
parent
3c6b885391
commit
5decb702f2
@@ -94,6 +94,7 @@ class OAuthsController < ApplicationController
|
||||
@user_email = query_path_from_object(user_profile, @o_auth.json_user_email_path)
|
||||
if not @o_auth.json_user_name_path.blank?
|
||||
@user_name = query_path_from_object(user_profile, @o_auth.json_user_name_path)
|
||||
@user_name = @user_name || I18n.t('defaults.user_full_name')
|
||||
end
|
||||
|
||||
@o_auth_login_completed = (not @user_email.blank?)
|
||||
|
||||
@@ -73,7 +73,7 @@ const TenantSignUpP = ({
|
||||
const [goneBack, setGoneBack] = useState(false);
|
||||
|
||||
const [userData, setUserData] = useState({
|
||||
fullName: oAuthLoginCompleted ? oauthUserName : '',
|
||||
fullName: (oAuthLoginCompleted && oauthUserName) ? oauthUserName.slice(0, 64) : '',
|
||||
email: oAuthLoginCompleted ? oauthUserEmail : '',
|
||||
password: '',
|
||||
passwordConfirmation: '',
|
||||
|
||||
@@ -102,13 +102,15 @@ const UserSignUpForm = ({
|
||||
|
||||
<div className="formRow">
|
||||
<input
|
||||
{...register('fullName', { required: true, minLength: 2 })}
|
||||
{...register('fullName', { required: true, minLength: 2, maxLength: 64 })}
|
||||
autoFocus
|
||||
placeholder={getLabel('user', 'full_name')}
|
||||
id="userFullName"
|
||||
className="formControl"
|
||||
/>
|
||||
<DangerText>{errors.fullName && getValidationMessage('required', 'user', 'full_name')}</DangerText>
|
||||
<DangerText>{errors.fullName?.type === 'required' && getValidationMessage('required', 'user', 'full_name')}</DangerText>
|
||||
<DangerText>{errors.fullName?.type === 'minLength' && (getLabel('user', 'full_name') + ' ' + I18n.t('activerecord.errors.messages.too_short', { count: 2 }))}</DangerText>
|
||||
<DangerText>{errors.fullName?.type === 'maxLength' && (getLabel('user', 'full_name') + ' ' + I18n.t('activerecord.errors.messages.too_long', { count: 64 }))}</DangerText>
|
||||
</div>
|
||||
|
||||
<div className="formRow">
|
||||
|
||||
@@ -17,7 +17,7 @@ class User < ApplicationRecord
|
||||
after_initialize :set_default_role, if: :new_record?
|
||||
after_initialize :set_default_status, if: :new_record?
|
||||
|
||||
validates :full_name, presence: true, length: { in: 2..32 }
|
||||
validates :full_name, presence: true, length: { in: 2..64 }
|
||||
validates :email,
|
||||
presence: true,
|
||||
uniqueness: { scope: :tenant_id, case_sensitive: false },
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<li class="nav-item dropdown">
|
||||
<a class="profileToggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<%= image_tag(current_user.gravatar_url, class: 'gravatar', alt: current_user.full_name, size: 24) %>
|
||||
<span class="fullname"><%= current_user.full_name %></span>
|
||||
<span class="fullname"><%= current_user.full_name.truncate(24) %></span>
|
||||
<% if current_user.moderator? && Post.pending.length > 0 %>
|
||||
<span class="notificationDot notificationDotTop"><%= Post.pending.length %></span>
|
||||
<% end %>
|
||||
|
||||
@@ -52,11 +52,11 @@ RSpec.describe User, type: :model do
|
||||
expect(empty_name_user).to be_invalid
|
||||
end
|
||||
|
||||
it 'has a full name between 2 and 32 characters' do
|
||||
it 'has a full name between 2 and 64 characters' do
|
||||
too_short_user = FactoryBot.build(:user, full_name: 'a' * 1)
|
||||
short_user = FactoryBot.build(:user, full_name: 'a' * 2)
|
||||
long_user = FactoryBot.build(:user, full_name: 'a' * 32)
|
||||
too_long_user = FactoryBot.build(:user, full_name: 'a' * 33)
|
||||
long_user = FactoryBot.build(:user, full_name: 'a' * 64)
|
||||
too_long_user = FactoryBot.build(:user, full_name: 'a' * 65)
|
||||
|
||||
expect(too_short_user).to be_invalid
|
||||
expect(short_user).to be_valid
|
||||
|
||||
Reference in New Issue
Block a user