fix user name by adding username cookie
This commit is contained in:
parent
eb26054c74
commit
139bc324e8
@ -1,4 +1,4 @@
|
||||
import {requestPVE, goToPage, instances} from "./utils.js";
|
||||
import {requestPVE, goToPage, instances, getCookie} from "./utils.js";
|
||||
|
||||
export class Instance extends HTMLElement {
|
||||
constructor () {
|
||||
@ -131,7 +131,7 @@ export class Instance extends HTMLElement {
|
||||
|
||||
handleConsoleButton () {
|
||||
if (this.status === "running") {
|
||||
goToPage("pve-xtermjs/index.html", {type: this.type, vmid: this.vmid, name: this.name, node: this.node.name, user: "alu@ldap", url: "pve.tronnet.net/api2/json"});
|
||||
goToPage("pve-xtermjs/index.html", {type: this.type, vmid: this.vmid, name: this.name, node: this.node.name, user: getCookie("username"), url: "pve.tronnet.net/api2/json"});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ function init (){
|
||||
try {
|
||||
status.innerText = "Authenticating...";
|
||||
let ticket = await requestTicket(formData.get("username"), formData.get("password"));
|
||||
setTicket(ticket.data.ticket, ticket.data.CSRFPreventionToken);
|
||||
setTicket(ticket.data.ticket, ticket.data.CSRFPreventionToken, formData.get("username"));
|
||||
status.innerText = "Authentication successful!"
|
||||
status.style.color = "#00ff00";
|
||||
goToPage("index.html");
|
||||
|
@ -59,7 +59,7 @@ export const instances = {
|
||||
}
|
||||
}
|
||||
|
||||
function getCookie(cname) {
|
||||
export function getCookie(cname) {
|
||||
let name = cname + "=";
|
||||
let decodedCookie = decodeURIComponent(document.cookie);
|
||||
let ca = decodedCookie.split(";");
|
||||
@ -81,11 +81,12 @@ export async function requestTicket (username, password) {
|
||||
return response;
|
||||
}
|
||||
|
||||
export function setTicket (ticket, csrf) {
|
||||
export function setTicket (ticket, csrf, username) {
|
||||
let d = new Date();
|
||||
d.setTime(d.getTime() + (2*60*60*1000));
|
||||
document.cookie = `PVEAuthCookie=${ticket}; path=/; expires=${d.toUTCString()}; domain=.tronnet.net`;
|
||||
document.cookie = `CSRFPreventionToken=${csrf}; path=/; expires=${d.toUTCString()}; domain=.tronnet.net;`
|
||||
document.cookie = `username=${username}@ldap; path=/; expires=${d.toUTCString()}; domain=.tronnet.net;`
|
||||
}
|
||||
|
||||
export async function requestPVE (path, method, body = null) {
|
||||
|
Loading…
Reference in New Issue
Block a user