fix: get auth method from the frontend constants
This commit is contained in:
parent
3aa5d91463
commit
ce81b8bcab
@ -4,10 +4,6 @@ export function get() {
|
|||||||
return fetchJSON<ISettings>(`/api/settings`, {});
|
return fetchJSON<ISettings>(`/api/settings`, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAuthMethod() {
|
|
||||||
return fetchJSON<{ authMethod: string }>(`/api/settings/auth-method`, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function update(settings: ISettings) {
|
export async function update(settings: ISettings) {
|
||||||
await fetchURL(`/api/settings`, {
|
await fetchURL(`/api/settings`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
|
|||||||
@ -96,11 +96,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useAuthStore } from "@/stores/auth";
|
import { useAuthStore } from "@/stores/auth";
|
||||||
import { useLayoutStore } from "@/stores/layout";
|
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 AceEditorTheme from "@/components/settings/AceEditorTheme.vue";
|
||||||
import Languages from "@/components/settings/Languages.vue";
|
import Languages from "@/components/settings/Languages.vue";
|
||||||
import { computed, inject, onMounted, ref } from "vue";
|
import { computed, inject, onMounted, ref } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
import { authMethod } from "@/utils/constants";
|
||||||
|
|
||||||
const layoutStore = useLayoutStore();
|
const layoutStore = useLayoutStore();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
@ -142,7 +143,6 @@ onMounted(async () => {
|
|||||||
dateFormat.value = authStore.user.dateFormat;
|
dateFormat.value = authStore.user.dateFormat;
|
||||||
aceEditorTheme.value = authStore.user.aceEditorTheme;
|
aceEditorTheme.value = authStore.user.aceEditorTheme;
|
||||||
layoutStore.loading = false;
|
layoutStore.loading = false;
|
||||||
const { authMethod } = await settings.getAuthMethod();
|
|
||||||
isCurrentPasswordRequired.value = authMethod == "json";
|
isCurrentPasswordRequired.value = authMethod == "json";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -71,6 +71,7 @@ import { computed, inject, onMounted, ref, watch } from "vue";
|
|||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { StatusError } from "@/api/utils";
|
import { StatusError } from "@/api/utils";
|
||||||
|
import { authMethod } from "@/utils/constants";
|
||||||
|
|
||||||
const error = ref<StatusError>();
|
const error = ref<StatusError>();
|
||||||
const originalUser = ref<IUser>();
|
const originalUser = ref<IUser>();
|
||||||
@ -105,11 +106,7 @@ const fetchData = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (isNew.value) {
|
if (isNew.value) {
|
||||||
const {
|
const { defaults, createUserDir: _createUserDir } = await settings.get();
|
||||||
authMethod,
|
|
||||||
defaults,
|
|
||||||
createUserDir: _createUserDir,
|
|
||||||
} = await settings.get();
|
|
||||||
isCurrentPasswordRequired.value = authMethod == "json";
|
isCurrentPasswordRequired.value = authMethod == "json";
|
||||||
createUserDir.value = _createUserDir;
|
createUserDir.value = _createUserDir;
|
||||||
user.value = {
|
user.value = {
|
||||||
|
|||||||
@ -80,7 +80,6 @@ func NewHandler(
|
|||||||
api.PathPrefix("/share").Handler(monkey(shareDeleteHandler, "/api/share")).Methods("DELETE")
|
api.PathPrefix("/share").Handler(monkey(shareDeleteHandler, "/api/share")).Methods("DELETE")
|
||||||
|
|
||||||
api.Handle("/settings", monkey(settingsGetHandler, "")).Methods("GET")
|
api.Handle("/settings", monkey(settingsGetHandler, "")).Methods("GET")
|
||||||
api.Handle("/settings/auth-method", monkey(authMethodGetHandler, "")).Methods("GET")
|
|
||||||
api.Handle("/settings", monkey(settingsPutHandler, "")).Methods("PUT")
|
api.Handle("/settings", monkey(settingsPutHandler, "")).Methods("PUT")
|
||||||
|
|
||||||
api.PathPrefix("/raw").Handler(monkey(rawHandler, "/api/raw")).Methods("GET")
|
api.PathPrefix("/raw").Handler(monkey(rawHandler, "/api/raw")).Methods("GET")
|
||||||
|
|||||||
@ -42,14 +42,6 @@ var settingsGetHandler = withAdmin(func(w http.ResponseWriter, r *http.Request,
|
|||||||
return renderJSON(w, r, data)
|
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) {
|
var settingsPutHandler = withAdmin(func(_ http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||||
req := &settingsData{}
|
req := &settingsData{}
|
||||||
err := json.NewDecoder(r.Body).Decode(req)
|
err := json.NewDecoder(r.Body).Decode(req)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user