mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 15:42:59 +00:00 
			
		
		
		
	
							
								
								
									
										13
									
								
								boot/boot.js
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								boot/boot.js
									
									
									
									
									
								
							| @@ -477,6 +477,7 @@ submitText: text to use for submit button (defaults to "Login") | ||||
| serviceName: text of the human readable service name | ||||
| noUserName: set true to disable username prompt | ||||
| canCancel: set true to enable a cancel button (callback called with null) | ||||
| repeatPassword: set true to prompt for the password twice | ||||
| callback: function to be called on submission with parameter of object {username:,password:}. Callback must return `true` to remove the password prompt | ||||
| */ | ||||
| $tw.utils.PasswordPrompt.prototype.createPrompt = function(options) { | ||||
| @@ -493,6 +494,11 @@ $tw.utils.PasswordPrompt.prototype.createPrompt = function(options) { | ||||
| 	children.push(dm("input",{ | ||||
| 		attributes: {type: "password", name: "password", placeholder: "Password"} | ||||
| 	})); | ||||
| 	if(options.repeatPassword) { | ||||
| 		children.push(dm("input",{ | ||||
| 			attributes: {type: "password", name: "password2", placeholder: "Repeat password"} | ||||
| 		})); | ||||
| 	} | ||||
| 	if(options.canCancel) { | ||||
| 		children.push(dm("button",{ | ||||
| 			text: "Cancel", | ||||
| @@ -527,6 +533,10 @@ $tw.utils.PasswordPrompt.prototype.createPrompt = function(options) { | ||||
| 				data[element.name] = element.value; | ||||
| 			} | ||||
| 		}); | ||||
| 		// Check that the passwords match | ||||
| 		if(options.repeatPassword && data.password !== data.password2) { | ||||
| 			alert("Passwords do not match"); | ||||
| 		} else { | ||||
| 			// Call the callback | ||||
| 			if(options.callback(data)) { | ||||
| 				// Remove the prompt if the callback returned true | ||||
| @@ -534,11 +544,12 @@ $tw.utils.PasswordPrompt.prototype.createPrompt = function(options) { | ||||
| 			} else { | ||||
| 				// Clear the password if the callback returned false | ||||
| 				$tw.utils.each(form.elements,function(element) { | ||||
| 				if(element.name === "password") { | ||||
| 					if(element.name === "password" || element.name === "password2") { | ||||
| 						element.value = ""; | ||||
| 					} | ||||
| 				}); | ||||
| 			} | ||||
| 		}  | ||||
| 		event.preventDefault(); | ||||
| 		return false; | ||||
| 	},true); | ||||
|   | ||||
| @@ -25,6 +25,7 @@ exports.startup = function() { | ||||
| 			noUserName: true, | ||||
| 			submitText: "Set password", | ||||
| 			canCancel: true, | ||||
| 			repeatPassword: true, | ||||
| 			callback: function(data) { | ||||
| 				if(data) { | ||||
| 					$tw.crypto.setPassword(data.password); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jermolene
					Jermolene