Skip to content

Fix password validation to allow slash character #2171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions services/app/apps/codebattle/assets/js/widgets/formik/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,41 +49,41 @@ const schemas = {
password: Yup.string().required('Password required'),
},
signUp: {
name: Yup
.string()
.test(
'start-or-end-with-empty-symbols',
'Can\'t start or end with empty symbols',
value => {
if (!value) {
return true;
}
const invalidSymbolIndex = invalidSymbols.findIndex(invalidSymbol => (
value.startsWith(invalidSymbol) || value.endsWith(invalidSymbol)
));
name: Yup
.string()
.test(
'start-or-end-with-empty-symbols',
'Can\'t start or end with empty symbols',
value => {
if (!value) {
return true;
}
const invalidSymbolIndex = invalidSymbols.findIndex(invalidSymbol => (
value.startsWith(invalidSymbol) || value.endsWith(invalidSymbol)
));

return invalidSymbolIndex === -1;
},
)
.min(3, 'Should be from 3 to 16 characters')
.max(16, 'Should be from 3 to 16 characters')
.matches(
/^[a-zA-Z]+[a-zA-Z0-9_-\s{1}][a-zA-Z0-9_]+$/i,
'Must consist of Latin letters, numbers and underscores. Only begin with latin letter',
)
.required('Nickname required'),
email: emailSchema,
password: Yup
.string()
.matches(/^\S*$/, 'Can\'t contain empty symbols')
.min(6, 'Should be from 6 to 16 characters')
.max(16, 'Should be from 6 to 16 characters')
.matches(/[!@#$%^&*(),.?":{}|<>]/, 'Should contain at least one special character')
.required('Password required'),
passwordConfirmation: Yup
.string()
.required('Confirmation required')
.oneOf([Yup.ref('password')], 'Passwords must match'),
return invalidSymbolIndex === -1;
},
)
.min(3, 'Should be from 3 to 16 characters')
.max(16, 'Should be from 3 to 16 characters')
.matches(
/^[a-zA-Z]+[a-zA-Z0-9_-\s{1}][a-zA-Z0-9_]+$/i,
'Must consist of Latin letters, numbers and underscores. Only begin with latin letter',
)
.required('Nickname required'),
email: emailSchema,
password: Yup
.string()
.matches(/^\S*$/, 'Can\'t contain empty symbols')
.min(6, 'Should be from 6 to 16 characters')
.max(16, 'Should be from 6 to 16 characters')
.matches(/[!@#$%^&*(),.?":{}|<>/\\]/, 'Should contain at least one special character')
.required('Password required'),
passwordConfirmation: Yup
.string()
.required('Confirmation required')
.oneOf([Yup.ref('password')], 'Passwords must match'),
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from 'react';
import { useSelector } from 'react-redux';

import i18next from 'i18next';
import { useSelector } from 'react-redux';

import RoomContext from '../../components/RoomContext';
import {
Expand All @@ -10,12 +10,12 @@ import {
import * as selectors from '../../selectors';
import useMachineStateSelector from '../../utils/useMachineStateSelector';

import TournamentCurrentPlayerRankingPanel from './TournamentCurrentPlayerRankingPanel';
import ChatWidget from './ChatWidget';
import Output from './Output';
import OutputTab from './OutputTab';
import TaskAssignment from './TaskAssignment';
import TimerContainer from './TimerContainer';
import TournamentCurrentPlayerRankingPanel from './TournamentCurrentPlayerRankingPanel';

const InfoPanel = ({
idOutput = 'leftOutput',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import React, { memo } from 'react';

import TournamentRankingTable from './TournamentRankingTable';
import Notifications from './Notifications';
import TournamentRankingTable from './TournamentRankingTable';

const TournamentCurrentPlayerRankingPanel = () => {
return (
<div
className="d-flex flex-wrap flex-sm-nowrap shadow-sm h-100 rounded-lg bg-white"
>
<TournamentRankingTable />
<div className="flex-shrink-1 p-0 border-left rounded-right cb-game-control-container">
<div className="d-flex flex-column justify-content-start overflow-auto h-100">
<div className="px-3 py-3 w-100 d-flex flex-column">
<Notifications />
</div>
const TournamentCurrentPlayerRankingPanel = () => (
<div
className="d-flex flex-wrap flex-sm-nowrap shadow-sm h-100 rounded-lg bg-white"
>
<TournamentRankingTable />
<div className="flex-shrink-1 p-0 border-left rounded-right cb-game-control-container">
<div className="d-flex flex-column justify-content-start overflow-auto h-100">
<div className="px-3 py-3 w-100 d-flex flex-column">
<Notifications />
</div>
</div>
</div>
</div>
);
};

export default memo(TournamentCurrentPlayerRankingPanel);
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const tableDataCellClassName = cn(
const TournamentRankingTable = () => {
const currentUserClanId = useSelector(currentUserClanIdSelector);
const { ranking } = useSelector(tournamentSelector);
console.log(ranking)
console.log(ranking);

return (
<div
Expand Down Expand Up @@ -79,7 +79,9 @@ const TournamentRankingTable = () => {
<div
title={item?.name}
className="cb-custom-event-name"
style={{ textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap', maxWidth: '13ch' }}
style={{
textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap', maxWidth: '13ch',
}}
>
{item?.name.slice(0, 11) + (item?.name.length > 11 ? '...' : '')}
</div>
Expand All @@ -88,7 +90,9 @@ const TournamentRankingTable = () => {
<div
title={console.log(item) || item?.clan}
className="cb-custom-event-name"
style={{ textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap', maxWidth: '15ch' }}
style={{
textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap', maxWidth: '15ch',
}}
>
{item?.clan?.slice(0, 11) + (item?.clan?.length > 11 ? '...' : '')}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const currentUserIdSelector = state => state.user.currentUserId;
export const currentUserClanIdSelector = state => state.user.users[state.user.currentUserId].clanId;

export const currentUserIsAdminSelector = state => !!state.user.users[state.user.currentUserId].isAdmin;
export const currentUserIsPremiumSelector = state => state.user.users[state.user.currentUserId].subscriptionType === SubscriptionTypeCodes.premium
export const currentUserIsPremiumSelector = state => state.user.users[state.user.currentUserId].subscriptionType === SubscriptionTypeCodes.premium;

export const currentUserIsGuestSelector = state => !!state.user.users[state.user.currentUserId].isGuest;

Expand Down