fix: get auth method from the frontend constants

This commit is contained in:
ArielLeyva 2026-01-08 09:55:41 -05:00
parent 3aa5d91463
commit ce81b8bcab
5 changed files with 4 additions and 20 deletions

View File

@ -4,10 +4,6 @@ export function get() {
return fetchJSON<ISettings>(`/api/settings`, {});
}
export function getAuthMethod() {
return fetchJSON<{ authMethod: string }>(`/api/settings/auth-method`, {});
}
export async function update(settings: ISettings) {
await fetchURL(`/api/settings`, {
method: "PUT",

View File

@ -96,11 +96,12 @@
<script setup lang="ts">
import { useAuthStore } from "@/stores/auth";
import { useLayoutStore } from "@/stores/layout";
import { users as api, settings } from "@/api";
import { users as api } from "@/api";
import AceEditorTheme from "@/components/settings/AceEditorTheme.vue";
import Languages from "@/components/settings/Languages.vue";
import { computed, inject, onMounted, ref } from "vue";
import { useI18n } from "vue-i18n";
import { authMethod } from "@/utils/constants";
const layoutStore = useLayoutStore();
const authStore = useAuthStore();
@ -142,7 +143,6 @@ onMounted(async () => {
dateFormat.value = authStore.user.dateFormat;
aceEditorTheme.value = authStore.user.aceEditorTheme;
layoutStore.loading = false;
const { authMethod } = await settings.getAuthMethod();
isCurrentPasswordRequired.value = authMethod == "json";
return true;

View File

@ -71,6 +71,7 @@ import { computed, inject, onMounted, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
import { StatusError } from "@/api/utils";
import { authMethod } from "@/utils/constants";
const error = ref<StatusError>();
const originalUser = ref<IUser>();
@ -105,11 +106,7 @@ const fetchData = async () => {
try {
if (isNew.value) {
const {
authMethod,
defaults,
createUserDir: _createUserDir,
} = await settings.get();
const { defaults, createUserDir: _createUserDir } = await settings.get();
isCurrentPasswordRequired.value = authMethod == "json";
createUserDir.value = _createUserDir;
user.value = {

View File

@ -80,7 +80,6 @@ func NewHandler(
api.PathPrefix("/share").Handler(monkey(shareDeleteHandler, "/api/share")).Methods("DELETE")
api.Handle("/settings", monkey(settingsGetHandler, "")).Methods("GET")
api.Handle("/settings/auth-method", monkey(authMethodGetHandler, "")).Methods("GET")
api.Handle("/settings", monkey(settingsPutHandler, "")).Methods("PUT")
api.PathPrefix("/raw").Handler(monkey(rawHandler, "/api/raw")).Methods("GET")

View File

@ -42,14 +42,6 @@ var settingsGetHandler = withAdmin(func(w http.ResponseWriter, r *http.Request,
return renderJSON(w, r, data)
})
var authMethodGetHandler = func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
data := &settingsData{
AuthMethod: d.settings.AuthMethod,
}
return renderJSON(w, r, data)
}
var settingsPutHandler = withAdmin(func(_ http.ResponseWriter, r *http.Request, d *data) (int, error) {
req := &settingsData{}
err := json.NewDecoder(r.Body).Decode(req)