diff --git a/src/components/CommunityComponents/CommunityHome.vue b/src/components/CommunityComponents/CommunityHome.vue index a625f2fe57ceaac318b237ee858d440f39a0005b..35542263915a810f46645b220d8d076783e4eeae 100644 --- a/src/components/CommunityComponents/CommunityHome.vue +++ b/src/components/CommunityComponents/CommunityHome.vue @@ -138,7 +138,6 @@ export default { this.items = await GetListingsInCommunity(this.communityID); for (var i = 0; i < this.items.length; i++) { let images = await getItemPictures(this.items[i].listingID); - console.log(images); if (images.length > 0) { this.items[i].img = images[0].picture; } diff --git a/src/components/FormComponents/NewPasswordForm.vue b/src/components/FormComponents/NewPasswordForm.vue index d13c08349360250ff4f0cf96b5f3faab00d7a841..f9a9c779db23ef5d16e6871d1edac10fd7b7e55b 100644 --- a/src/components/FormComponents/NewPasswordForm.vue +++ b/src/components/FormComponents/NewPasswordForm.vue @@ -134,12 +134,19 @@ export default { return; } - const newPasswordInfo = { - token: this.token, - newPassword: this.password, - }; + const newPassword = this.user.password; - const newPasswordResponse = doNewPassword(newPasswordInfo); + const newPasswordResponse = await doNewPassword(newPassword); + + if (newPasswordResponse != null) { + console.log("New password set"); + this.$store.commit("saveToken", newPasswordResponse); + await this.$router.push("/"); + } else { + console.log("Couldn't set new password"); + } + + /* if (newPasswordResponse.newPasswordSet === true) { console.log("New password set"); @@ -149,6 +156,8 @@ export default { } else { console.log("Something went wrong"); } + + */ }, validate() { this.$refs.form.validate(); diff --git a/src/utils/apiutil.js b/src/utils/apiutil.js index a49864af94949186bb90b327a95ad74cc4dc9d37..1397849ea208d2760f3b8ac372ba1d6820892d73 100644 --- a/src/utils/apiutil.js +++ b/src/utils/apiutil.js @@ -84,15 +84,22 @@ export function getAverageRating(userid) { console.error(error); }); } -export function doNewPassword() { - //m - //add newPasswordInfo to input - const auth = { newPasswordSet: false }; - //return axios - //.post(API_URL + "newPassword", newPasswordInfo) - //.then((response) => {auth.newPasswordSet = true;return auth;}) - //.catch((error) => {console.log(error);return auth;}); - return auth; //remove after axios is added +export async function doNewPassword(password) { + let res = await axios({ + method: "put", + url: API_URL + "user/profile/password", + headers: tokenHeader(), + data: { + password: password, + }, + }) + .then((response) => { + return response; + }) + .catch((error) => { + console.log(error); + }); + return res.data; } export function postNewItem(itemInfo) {