mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +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)
|
@user_email = query_path_from_object(user_profile, @o_auth.json_user_email_path)
|
||||||
if not @o_auth.json_user_name_path.blank?
|
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 = query_path_from_object(user_profile, @o_auth.json_user_name_path)
|
||||||
|
@user_name = @user_name || I18n.t('defaults.user_full_name')
|
||||||
end
|
end
|
||||||
|
|
||||||
@o_auth_login_completed = (not @user_email.blank?)
|
@o_auth_login_completed = (not @user_email.blank?)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ const TenantSignUpP = ({
|
|||||||
const [goneBack, setGoneBack] = useState(false);
|
const [goneBack, setGoneBack] = useState(false);
|
||||||
|
|
||||||
const [userData, setUserData] = useState({
|
const [userData, setUserData] = useState({
|
||||||
fullName: oAuthLoginCompleted ? oauthUserName : '',
|
fullName: (oAuthLoginCompleted && oauthUserName) ? oauthUserName.slice(0, 64) : '',
|
||||||
email: oAuthLoginCompleted ? oauthUserEmail : '',
|
email: oAuthLoginCompleted ? oauthUserEmail : '',
|
||||||
password: '',
|
password: '',
|
||||||
passwordConfirmation: '',
|
passwordConfirmation: '',
|
||||||
|
|||||||
@@ -102,13 +102,15 @@ const UserSignUpForm = ({
|
|||||||
|
|
||||||
<div className="formRow">
|
<div className="formRow">
|
||||||
<input
|
<input
|
||||||
{...register('fullName', { required: true, minLength: 2 })}
|
{...register('fullName', { required: true, minLength: 2, maxLength: 64 })}
|
||||||
autoFocus
|
autoFocus
|
||||||
placeholder={getLabel('user', 'full_name')}
|
placeholder={getLabel('user', 'full_name')}
|
||||||
id="userFullName"
|
id="userFullName"
|
||||||
className="formControl"
|
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>
|
||||||
|
|
||||||
<div className="formRow">
|
<div className="formRow">
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class User < ApplicationRecord
|
|||||||
after_initialize :set_default_role, if: :new_record?
|
after_initialize :set_default_role, if: :new_record?
|
||||||
after_initialize :set_default_status, 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,
|
validates :email,
|
||||||
presence: true,
|
presence: true,
|
||||||
uniqueness: { scope: :tenant_id, case_sensitive: false },
|
uniqueness: { scope: :tenant_id, case_sensitive: false },
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="profileToggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<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) %>
|
<%= 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 %>
|
<% if current_user.moderator? && Post.pending.length > 0 %>
|
||||||
<span class="notificationDot notificationDotTop"><%= Post.pending.length %></span>
|
<span class="notificationDot notificationDotTop"><%= Post.pending.length %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -52,11 +52,11 @@ RSpec.describe User, type: :model do
|
|||||||
expect(empty_name_user).to be_invalid
|
expect(empty_name_user).to be_invalid
|
||||||
end
|
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)
|
too_short_user = FactoryBot.build(:user, full_name: 'a' * 1)
|
||||||
short_user = FactoryBot.build(:user, full_name: 'a' * 2)
|
short_user = FactoryBot.build(:user, full_name: 'a' * 2)
|
||||||
long_user = FactoryBot.build(:user, full_name: 'a' * 32)
|
long_user = FactoryBot.build(:user, full_name: 'a' * 64)
|
||||||
too_long_user = FactoryBot.build(:user, full_name: 'a' * 33)
|
too_long_user = FactoryBot.build(:user, full_name: 'a' * 65)
|
||||||
|
|
||||||
expect(too_short_user).to be_invalid
|
expect(too_short_user).to be_invalid
|
||||||
expect(short_user).to be_valid
|
expect(short_user).to be_valid
|
||||||
|
|||||||
Reference in New Issue
Block a user