mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 11:08:04 +00:00 
			
		
		
		
	 4014a846f0
			
		
	
	4014a846f0
	
	
	
		
			
			FE support for https://github.com/chatwoot/chatwoot/pull/12290 ## Linear: - https://github.com/chatwoot/chatwoot/issues/486 ## Description This PR implements Multi-Factor Authentication (MFA) support for user accounts, enhancing security by requiring a second form of verification during login. The feature adds TOTP (Time-based One-Time Password) authentication with QR code generation and backup codes for account recovery. ## Type of change - [ ] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Added comprehensive RSpec tests for MFA controller functionality - Tested MFA setup flow with QR code generation - Verified OTP validation and backup code generation - Tested login flow with MFA enabled/disabled ## Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: Pranav <pranav@chatwoot.com> Co-authored-by: iamsivin <iamsivin@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Sojan Jose <sojan@pepalo.com>
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /**
 | |
|  * Writes a text string to the system clipboard.
 | |
|  *
 | |
|  * @async
 | |
|  * @param {string} data text to be written to the clipboard
 | |
|  * @throws {Error} unable to copy text to clipboard
 | |
|  */
 | |
| export const copyTextToClipboard = async data => {
 | |
|   try {
 | |
|     const text =
 | |
|       typeof data === 'object' && data !== null
 | |
|         ? JSON.stringify(data, null, 2)
 | |
|         : String(data ?? '');
 | |
| 
 | |
|     await navigator.clipboard.writeText(text);
 | |
|   } catch (error) {
 | |
|     throw new Error(`Unable to copy text to clipboard: ${error.message}`);
 | |
|   }
 | |
| };
 | |
| 
 | |
| /**
 | |
|  * Handles OTP paste events by extracting numeric digits from clipboard data.
 | |
|  *
 | |
|  * @param {ClipboardEvent} event - The paste event from the clipboard
 | |
|  * @param {number} maxLength - Maximum number of digits to extract (default: 6)
 | |
|  * @returns {string|null} - Extracted numeric string or null if invalid
 | |
|  */
 | |
| export const handleOtpPaste = (event, maxLength = 6) => {
 | |
|   if (!event?.clipboardData) return null;
 | |
| 
 | |
|   const pastedData = event.clipboardData
 | |
|     .getData('text')
 | |
|     .replace(/\D/g, '') // Remove all non-digit characters
 | |
|     .slice(0, maxLength); // Limit to maxLength digits
 | |
| 
 | |
|   // Only return if we have the exact expected length
 | |
|   return pastedData.length === maxLength ? pastedData : null;
 | |
| };
 |