mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-02-14 14:01:51 +00:00
add SSH key check
This commit is contained in:
parent
8bf49a664a
commit
2693f6f138
1 changed files with 4 additions and 1 deletions
|
@ -267,6 +267,7 @@ $("#create-vm").click(function(){
|
|||
const max_cpu = $(this).data('max_cpu');
|
||||
const max_mem = $(this).data('max_mem');
|
||||
const max_disk = $(this).data('max_disk');
|
||||
var ssh_regex = new RegExp("ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?")
|
||||
var disk = document.getElementById('disk').value;
|
||||
fetch(`/template/${template}/disk`, {
|
||||
credentials: 'same-origin',
|
||||
|
@ -279,7 +280,9 @@ $("#create-vm").click(function(){
|
|||
return disk
|
||||
}).then((disk) => {
|
||||
if (name && disk) {
|
||||
if (disk > max_disk) {
|
||||
if (!ssh_regex.test(ssh_key)) {
|
||||
swal("Uh oh...", "Invalid SSH key!", "error");
|
||||
} else if (disk > max_disk) {
|
||||
swal("Uh oh...", `You do not have enough disk resources available! Please lower the VM disk size to ${max_disk}GB or lower.`, "error");
|
||||
} else if (template != 'none' && cores > max_cpu) {
|
||||
swal("Uh oh...", `You do not have enough CPU resources available! Please lower the VM cores to ${max_cpu} or lower.`, "error");
|
||||
|
|
Loading…
Reference in a new issue