Skip to content
Snippets Groups Projects
Commit 2b976bc8 authored by Erik Borgeteien Hansen's avatar Erik Borgeteien Hansen
Browse files

Merge branch 'change-password' into 'main'

Change password

See merge request !85
parents 7ad2e244 18585c62
No related branches found
No related tags found
1 merge request!85Change password
Pipeline #179950 passed
......@@ -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;
}
......
......@@ -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();
......
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment