mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 02:29:03 +00:00 
			
		
		
		
	Fix UI : Fix password validation while creating account (#7807)
* Fix the password validation while creating account * change error message for password validation * remove multiple error on field
This commit is contained in:
		
							parent
							
								
									3b57d726f8
								
							
						
					
					
						commit
						cc94b58168
					
				| @ -30,7 +30,11 @@ import React, { useRef, useState } from 'react'; | |||||||
| import { useAuthContext } from '../../authentication/auth-provider/AuthProvider'; | import { useAuthContext } from '../../authentication/auth-provider/AuthProvider'; | ||||||
| import { generateRandomPwd } from '../../axiosAPIs/auth-API'; | import { generateRandomPwd } from '../../axiosAPIs/auth-API'; | ||||||
| import { getBotsPagePath, getUsersPagePath } from '../../constants/constants'; | import { getBotsPagePath, getUsersPagePath } from '../../constants/constants'; | ||||||
| import { validEmailRegEx } from '../../constants/regex.constants'; | import { passwordErrorMessage } from '../../constants/error-message'; | ||||||
|  | import { | ||||||
|  |   passwordRegex, | ||||||
|  |   validEmailRegEx, | ||||||
|  | } from '../../constants/regex.constants'; | ||||||
| import { PageLayoutType } from '../../enums/layout.enum'; | import { PageLayoutType } from '../../enums/layout.enum'; | ||||||
| import { CreatePasswordGenerator } from '../../enums/user.enum'; | import { CreatePasswordGenerator } from '../../enums/user.enum'; | ||||||
| import { | import { | ||||||
| @ -792,6 +796,10 @@ const CreateUser = ({ | |||||||
|                   { |                   { | ||||||
|                     required: true, |                     required: true, | ||||||
|                   }, |                   }, | ||||||
|  |                   { | ||||||
|  |                     pattern: passwordRegex, | ||||||
|  |                     message: passwordErrorMessage, | ||||||
|  |                   }, | ||||||
|                 ]}> |                 ]}> | ||||||
|                 <Input.Password |                 <Input.Password | ||||||
|                   name="password" |                   name="password" | ||||||
| @ -805,9 +813,6 @@ const CreateUser = ({ | |||||||
|                 label="Confirm Password" |                 label="Confirm Password" | ||||||
|                 name="confirmPassword" |                 name="confirmPassword" | ||||||
|                 rules={[ |                 rules={[ | ||||||
|                   { |  | ||||||
|                     required: true, |  | ||||||
|                   }, |  | ||||||
|                   { |                   { | ||||||
|                     validator: (_, value) => { |                     validator: (_, value) => { | ||||||
|                       if (value !== password) { |                       if (value !== password) { | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| import { Form, Input, Modal } from 'antd'; | import { Form, Input, Modal } from 'antd'; | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
|  | import { passwordErrorMessage } from '../../constants/error-message'; | ||||||
|  | import { passwordRegex } from '../../constants/regex.constants'; | ||||||
| import { ChangePasswordRequest } from '../../generated/auth/changePasswordRequest'; | import { ChangePasswordRequest } from '../../generated/auth/changePasswordRequest'; | ||||||
| 
 | 
 | ||||||
| type ChangePasswordForm = { | type ChangePasswordForm = { | ||||||
| @ -63,6 +65,10 @@ const ChangePasswordForm: React.FC<ChangePasswordForm> = ({ | |||||||
|             { |             { | ||||||
|               required: true, |               required: true, | ||||||
|             }, |             }, | ||||||
|  |             { | ||||||
|  |               pattern: passwordRegex, | ||||||
|  |               message: passwordErrorMessage, | ||||||
|  |             }, | ||||||
|           ]}> |           ]}> | ||||||
|           <Input.Password placeholder="Enter New Password" /> |           <Input.Password placeholder="Enter New Password" /> | ||||||
|         </Form.Item> |         </Form.Item> | ||||||
| @ -70,9 +76,6 @@ const ChangePasswordForm: React.FC<ChangePasswordForm> = ({ | |||||||
|           label="Confirm New Password" |           label="Confirm New Password" | ||||||
|           name="confirmPassword" |           name="confirmPassword" | ||||||
|           rules={[ |           rules={[ | ||||||
|             { |  | ||||||
|               required: true, |  | ||||||
|             }, |  | ||||||
|             { |             { | ||||||
|               validator: (_, value) => { |               validator: (_, value) => { | ||||||
|                 if (value !== newPassword) { |                 if (value !== newPassword) { | ||||||
|  | |||||||
| @ -0,0 +1,15 @@ | |||||||
|  | /* | ||||||
|  |  *  Copyright 2022 Collate | ||||||
|  |  *  Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  |  *  you may not use this file except in compliance with the License. | ||||||
|  |  *  You may obtain a copy of the License at | ||||||
|  |  *  http://www.apache.org/licenses/LICENSE-2.0
 | ||||||
|  |  *  Unless required by applicable law or agreed to in writing, software | ||||||
|  |  *  distributed under the License is distributed on an "AS IS" BASIS, | ||||||
|  |  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
|  |  *  See the License for the specific language governing permissions and | ||||||
|  |  *  limitations under the License. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | export const passwordErrorMessage = | ||||||
|  |   'Password must be a minimum of 8 and a maximum of 16 characters long and contain at least one uppercase and one lowercase letter (A, z), and one special character (such as !, %, @, or #)'; | ||||||
| @ -19,6 +19,8 @@ import loginBG from '../../assets/img/login-bg.png'; | |||||||
| import { useAuthContext } from '../../authentication/auth-provider/AuthProvider'; | import { useAuthContext } from '../../authentication/auth-provider/AuthProvider'; | ||||||
| import { useBasicAuth } from '../../authentication/auth-provider/basic-auth.provider'; | import { useBasicAuth } from '../../authentication/auth-provider/basic-auth.provider'; | ||||||
| import { ROUTES } from '../../constants/constants'; | import { ROUTES } from '../../constants/constants'; | ||||||
|  | import { passwordErrorMessage } from '../../constants/error-message'; | ||||||
|  | import { passwordRegex } from '../../constants/regex.constants'; | ||||||
| import { AuthTypes } from '../../enums/signin.enum'; | import { AuthTypes } from '../../enums/signin.enum'; | ||||||
| import SVGIcons, { Icons } from '../../utils/SvgUtils'; | import SVGIcons, { Icons } from '../../utils/SvgUtils'; | ||||||
| import LoginCarousel from '../login/LoginCarousel'; | import LoginCarousel from '../login/LoginCarousel'; | ||||||
| @ -111,17 +113,12 @@ const BasicSignUp = () => { | |||||||
|                           label="Password" |                           label="Password" | ||||||
|                           name="password" |                           name="password" | ||||||
|                           rules={[ |                           rules={[ | ||||||
|                             { required: true }, |  | ||||||
|                             { |                             { | ||||||
|                               validator: (_, value) => { |                               required: true, | ||||||
|                                 if (value < 8 && value > 16) { |                             }, | ||||||
|                                   return Promise.reject( |                             { | ||||||
|                                     'Password must be of minimum 8 and maximum 16 characters, with one special , one upper, one lower case character' |                               pattern: passwordRegex, | ||||||
|                                   ); |                               message: passwordErrorMessage, | ||||||
|                                 } |  | ||||||
| 
 |  | ||||||
|                                 return Promise.resolve(); |  | ||||||
|                               }, |  | ||||||
|                             }, |                             }, | ||||||
|                           ]}> |                           ]}> | ||||||
|                           <Input.Password placeholder="Enter password" /> |                           <Input.Password placeholder="Enter password" /> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Ashish Gupta
						Ashish Gupta