| 
									
										
										
										
											2024-03-21 19:25:07 +01:00
										 |  |  | import {LitElement, html} from './lit-all.min.js'; | 
					
						
							|  |  |  | import * as tfrpc from '/static/tfrpc.js'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class TfPasswordFormElement extends LitElement { | 
					
						
							|  |  |  | 	static get properties() { | 
					
						
							|  |  |  | 		return { | 
					
						
							|  |  |  | 			//selected: {type: String},
 | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	constructor() { | 
					
						
							|  |  |  | 		super(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * Checks a password against different requirements | 
					
						
							|  |  |  | 	 * @param {string} password the password to validate | 
					
						
							|  |  |  | 	 * @returns | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	validatePassword(password) { | 
					
						
							|  |  |  | 		// TODO(tasiaiso)
 | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	submitPassword() { | 
					
						
							|  |  |  | 		const currentPwd = this.shadowRoot.getElementById('current').value; | 
					
						
							|  |  |  | 		const newPwd = this.shadowRoot.getElementById('new').value; | 
					
						
							|  |  |  | 		const repeatPwd = this.shadowRoot.getElementById('Repeat').value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (!(newPwd === repeatPwd)) { | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// TODO
 | 
					
						
							|  |  |  | 		// tfrpc.changePassword()
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	render() { | 
					
						
							|  |  |  | 		return html`
 | 
					
						
							| 
									
										
										
										
											2024-03-21 20:10:35 +01:00
										 |  |  | 			<link rel="stylesheet" href="/static/tildefriends-v1.css" /> | 
					
						
							| 
									
										
										
										
											2024-03-21 19:25:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			<style> | 
					
						
							|  |  |  | 				.grid { | 
					
						
							|  |  |  | 					display: grid; | 
					
						
							|  |  |  | 					grid-template-columns: auto auto; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			</style> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			<div class="grid"> | 
					
						
							|  |  |  | 				<label for="current">Current password:</label> | 
					
						
							| 
									
										
										
										
											2024-03-21 20:10:35 +01:00
										 |  |  | 				<input | 
					
						
							|  |  |  | 					type="password" | 
					
						
							|  |  |  | 					id="current" | 
					
						
							|  |  |  | 					name="current" | 
					
						
							|  |  |  | 					autocomplete="current-password" | 
					
						
							|  |  |  | 				/> | 
					
						
							| 
									
										
										
										
											2024-03-21 19:25:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				<label for="new">Enter new password:</label> | 
					
						
							| 
									
										
										
										
											2024-03-21 20:10:35 +01:00
										 |  |  | 				<input | 
					
						
							|  |  |  | 					type="password" | 
					
						
							|  |  |  | 					id="new" | 
					
						
							|  |  |  | 					name="new" | 
					
						
							|  |  |  | 					autocomplete="new-password" | 
					
						
							|  |  |  | 				/> | 
					
						
							| 
									
										
										
										
											2024-03-21 19:25:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				<label for="repeat">Repeat new password:</label> | 
					
						
							| 
									
										
										
										
											2024-03-21 20:10:35 +01:00
										 |  |  | 				<input | 
					
						
							|  |  |  | 					type="password" | 
					
						
							|  |  |  | 					id="repeat" | 
					
						
							|  |  |  | 					name="repeat" | 
					
						
							|  |  |  | 					autocomplete="new-password" | 
					
						
							|  |  |  | 				/> | 
					
						
							| 
									
										
										
										
											2024-03-21 19:25:07 +01:00
										 |  |  | 			</div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			<button @click=${this.submitPassword} class="red"> | 
					
						
							|  |  |  | 				[Not implemented] Change my password | 
					
						
							|  |  |  | 			</button> | 
					
						
							|  |  |  | 		`;
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 20:10:35 +01:00
										 |  |  | customElements.define('tf-password-form', TfPasswordFormElement); |