nov showing a message that the rendez-vous id is generated.
This commit is contained in:
		
							parent
							
								
									04c8b441ac
								
							
						
					
					
						commit
						9f302fb457
					
				| @ -17,13 +17,11 @@ func generateCLIExammple(w http.ResponseWriter, r *http.Request) { | |||||||
| 		http.Error(w, "Error parsing form", http.StatusBadRequest) | 		http.Error(w, "Error parsing form", http.StatusBadRequest) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	ids := r.Form["rendez-vous-id"] | 	id := r.FormValue("rendez-vous-id") | ||||||
| 	id := "" | 	generatedId := false | ||||||
| 	if len(ids) > 0 { |  | ||||||
| 		id = strings.TrimSpace(ids[0]) |  | ||||||
| 	} |  | ||||||
| 	if id == "" { | 	if id == "" { | ||||||
| 		id = strconv.Itoa(rand.Int() % 1000000) | 		id = strconv.Itoa(rand.Int() % 1000000) | ||||||
|  | 		generatedId = true | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	remoteShells := r.Form["remote-shell"] | 	remoteShells := r.Form["remote-shell"] | ||||||
| @ -36,6 +34,9 @@ func generateCLIExammple(w http.ResponseWriter, r *http.Request) { | |||||||
| 	sshPublicKeys := strings.Split(keysString, "\n") | 	sshPublicKeys := strings.Split(keysString, "\n") | ||||||
| 	usageInputs := templates.NewUsageInputs(id, sshPublicKeys, remoteShells, localShells, downloadCommand, | 	usageInputs := templates.NewUsageInputs(id, sshPublicKeys, remoteShells, localShells, downloadCommand, | ||||||
| 		certificateValidation) | 		certificateValidation) | ||||||
|  | 	if generatedId { | ||||||
|  | 		usageInputs.ErrorMessages = append(usageInputs.ErrorMessages, "rendez-vous id is randomly generated, changes on every page refresh") | ||||||
|  | 	} | ||||||
| 	matched, _ := regexp.MatchString("^[a-zA-Z0-9-_]+$", id) | 	matched, _ := regexp.MatchString("^[a-zA-Z0-9-_]+$", id) | ||||||
| 	if !matched { | 	if !matched { | ||||||
| 		usageInputs.ErrorMessages = append(usageInputs.ErrorMessages, "ID may consist only of alphanumeric characters, '-', and '_'") | 		usageInputs.ErrorMessages = append(usageInputs.ErrorMessages, "ID may consist only of alphanumeric characters, '-', and '_'") | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user