mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-06 16:07:14 +08:00
fix: do not show auth when input wrong auth code (#23)
This commit is contained in:
@@ -33,7 +33,7 @@ const getOpenSettings = async (message) => {
|
|||||||
const res = await api.fetch("/open_api/settings");
|
const res = await api.fetch("/open_api/settings");
|
||||||
openSettings.value = {
|
openSettings.value = {
|
||||||
prefix: res["prefix"] || "",
|
prefix: res["prefix"] || "",
|
||||||
auth: res["auth"] || false,
|
needAuth: res["needAuth"] || false,
|
||||||
domains: res["domains"].map((domain) => {
|
domains: res["domains"].map((domain) => {
|
||||||
return {
|
return {
|
||||||
label: domain,
|
label: domain,
|
||||||
@@ -41,7 +41,7 @@ const getOpenSettings = async (message) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
if (openSettings.value.auth && !auth.value) {
|
if (openSettings.value.needAuth) {
|
||||||
showAuth.value = true;
|
showAuth.value = true;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export const useGlobalState = createGlobalState(
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const openSettings = ref({
|
const openSettings = ref({
|
||||||
prefix: '',
|
prefix: '',
|
||||||
auth: false,
|
needAuth: false,
|
||||||
domains: [{
|
domains: [{
|
||||||
label: 'test.com',
|
label: 'test.com',
|
||||||
value: 'test.com'
|
value: 'test.com'
|
||||||
|
|||||||
@@ -19,12 +19,16 @@ api.get('/api/settings', async (c) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
api.get('/open_api/settings', async (c) => {
|
api.get('/open_api/settings', async (c) => {
|
||||||
|
// check header x-custom-auth
|
||||||
|
let needAuth = false;
|
||||||
|
if (c.env.PASSWORDS && c.env.PASSWORDS.length > 0) {
|
||||||
|
const auth = c.req.headers.get("x-custom-auth");
|
||||||
|
needAuth = !c.env.PASSWORDS.includes(auth);
|
||||||
|
}
|
||||||
return c.json({
|
return c.json({
|
||||||
"prefix": c.env.PREFIX,
|
"prefix": c.env.PREFIX,
|
||||||
"domains": c.env.DOMAINS,
|
"domains": c.env.DOMAINS,
|
||||||
"auth": (
|
"needAuth": needAuth,
|
||||||
c.env.PASSWORDS && c.env.PASSWORDS.length > 0
|
|
||||||
) ? true : false,
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user