mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-25 15:52:43 +00:00
Compare commits
No commits in common. "c4839fb178a92a39219608e6ded848e051504e67" and "7b3c62b9162e01bd83e92ec4a166bf8d7d29b6f1" have entirely different histories.
c4839fb178
...
7b3c62b916
2 changed files with 51 additions and 2 deletions
|
|
@ -319,11 +319,19 @@
|
||||||
this.loading(false);
|
this.loading(false);
|
||||||
await this.updateAllSetting();
|
await this.updateAllSetting();
|
||||||
},
|
},
|
||||||
|
generateRandomString(length) {
|
||||||
|
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||||
|
let randomString = "";
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
randomString += chars[Math.floor(Math.random() * chars.length)];
|
||||||
|
}
|
||||||
|
return randomString;
|
||||||
|
},
|
||||||
async getNewSecret() {
|
async getNewSecret() {
|
||||||
if (!this.changeSecret) {
|
if (!this.changeSecret) {
|
||||||
this.changeSecret = true;
|
this.changeSecret = true;
|
||||||
this.user.loginSecret = '';
|
this.user.loginSecret = '';
|
||||||
const newSecret = RandomUtil.randomSeq(64);
|
const newSecret = this.generateRandomString(64);
|
||||||
await PromiseUtil.sleep(1000);
|
await PromiseUtil.sleep(1000);
|
||||||
this.user.loginSecret = newSecret;
|
this.user.loginSecret = newSecret;
|
||||||
this.changeSecret = false;
|
this.changeSecret = false;
|
||||||
|
|
|
||||||
|
|
@ -383,6 +383,47 @@
|
||||||
if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj);
|
if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async fetchUserSecret() {
|
||||||
|
this.loading(true);
|
||||||
|
const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
|
||||||
|
if (userMessage.success) {
|
||||||
|
this.user = userMessage.obj;
|
||||||
|
}
|
||||||
|
this.loading(false);
|
||||||
|
},
|
||||||
|
async updateSecret() {
|
||||||
|
this.loading(true);
|
||||||
|
const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
|
||||||
|
if (msg.success) {
|
||||||
|
this.user = msg.obj;
|
||||||
|
window.location.replace(basePath + "logout");
|
||||||
|
}
|
||||||
|
this.loading(false);
|
||||||
|
await this.updateXraySetting();
|
||||||
|
},
|
||||||
|
generateRandomString(length) {
|
||||||
|
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||||
|
let randomString = "";
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
randomString += chars[Math.floor(Math.random() * chars.length)];
|
||||||
|
}
|
||||||
|
return randomString;
|
||||||
|
},
|
||||||
|
async getNewSecret() {
|
||||||
|
this.loading(true);
|
||||||
|
await PromiseUtil.sleep(600);
|
||||||
|
const newSecret = this.generateRandomString(64);
|
||||||
|
this.user.loginSecret = newSecret;
|
||||||
|
document.getElementById("token").textContent = newSecret;
|
||||||
|
this.loading(false);
|
||||||
|
},
|
||||||
|
async toggleToken(value) {
|
||||||
|
if (value) {
|
||||||
|
await this.getNewSecret();
|
||||||
|
} else {
|
||||||
|
this.user.loginSecret = "";
|
||||||
|
}
|
||||||
|
},
|
||||||
async resetXrayConfigToDefault() {
|
async resetXrayConfigToDefault() {
|
||||||
this.loading(true);
|
this.loading(true);
|
||||||
const msg = await HttpUtil.get("/panel/setting/getDefaultJsonConfig");
|
const msg = await HttpUtil.get("/panel/setting/getDefaultJsonConfig");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue