Version
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
import https from "https";
|
||||
import { events } from "../globalEvents";
|
||||
import {
|
||||
ApGroup,
|
||||
ApRadioWifiUsage,
|
||||
@@ -57,13 +58,13 @@ export class UnifiClient {
|
||||
try {
|
||||
// UniFi OS
|
||||
const res = await this.client.post("/api/auth/login", body);
|
||||
console.log("Login OK (UniFi OS)", res.status);
|
||||
events.emit("unifi:login:ok", { type: "unifi-os", status: res.status });
|
||||
this.persistSession(res);
|
||||
} catch (e) {
|
||||
// Legacy controller
|
||||
console.log("UniFi OS login failed, trying legacy...");
|
||||
events.emit("unifi:login:fallback");
|
||||
const res = await this.client.post("/api/login", body);
|
||||
console.log("Login OK (legacy)", res.status);
|
||||
events.emit("unifi:login:ok", { type: "legacy", status: res.status });
|
||||
this.persistSession(res);
|
||||
}
|
||||
}
|
||||
@@ -78,13 +79,13 @@ export class UnifiClient {
|
||||
try {
|
||||
const res = await this.client.get(path);
|
||||
const data = (res.data?.data ?? res.data) as WlanConfRaw[];
|
||||
console.log(`Fetched wlan from ${path}`);
|
||||
events.emit("unifi:wlan:fetched", { path });
|
||||
return data;
|
||||
} catch (e) {
|
||||
console.log(
|
||||
`Failed ${path}:`,
|
||||
axios.isAxiosError(e) ? e.response?.status : e,
|
||||
);
|
||||
events.emit("unifi:wlan:fetch_failed", {
|
||||
path,
|
||||
status: axios.isAxiosError(e) ? e.response?.status : e,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user