Use new path of change_password API method

This commit is contained in:
silverpill 2022-11-25 23:51:20 +00:00
parent f5a5263725
commit f939d9ff9a
3 changed files with 20 additions and 20 deletions

View file

@ -1,5 +1,24 @@
import { BACKEND_URL } from "@/constants" import { BACKEND_URL } from "@/constants"
import { http } from "./common" import { http } from "./common"
import { User } from "./users"
export async function changePassword(
authToken: string,
newPassword: string,
): Promise<User> {
const url = `${BACKEND_URL}/api/v1/settings/change_password`
const response = await http(url, {
method: "POST",
json: { new_password: newPassword },
authToken,
})
const data = await response.json()
if (response.status !== 200) {
throw new Error(data.message)
} else {
return data
}
}
async function downloadBlob(blob: Blob) { async function downloadBlob(blob: Blob) {
const fileUrl = window.URL.createObjectURL(blob) const fileUrl = window.URL.createObjectURL(blob)

View file

@ -240,24 +240,6 @@ export async function updateProfile(
} }
} }
export async function changePassword(
authToken: string,
newPassword: string,
): Promise<User> {
const url = `${BACKEND_URL}/api/v1/accounts/change_password`
const response = await http(url, {
method: "POST",
json: { new_password: newPassword },
authToken,
})
const data = await response.json()
if (response.status !== 200) {
throw new Error(data.message)
} else {
return data
}
}
interface UnsignedActivity { interface UnsignedActivity {
internal_activity_id: string, internal_activity_id: string,
activity: string, activity: string,

View file

@ -60,8 +60,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { $, $ref } from "vue/macros" import { $, $ref } from "vue/macros"
import { exportFollowers, exportFollows } from "@/api/settings" import { changePassword, exportFollowers, exportFollows } from "@/api/settings"
import { changePassword } from "@/api/users"
import SidebarLayout from "@/components/SidebarLayout.vue" import SidebarLayout from "@/components/SidebarLayout.vue"
import { useCurrentUser } from "@/store/user" import { useCurrentUser } from "@/store/user"