edit account and logout feature

This commit is contained in:
Cindy Chang
2024-06-26 15:35:51 +08:00
parent 14783654a5
commit b2c084657d
8 changed files with 1617 additions and 1527 deletions

View File

@@ -123,6 +123,30 @@ export default defineStore('acctMgmtStore', {
return false;
};
},
/**
* Edit an account.
* @param {string} userToEdit this value is unique in database.
* @param {object} editDetail
*/
async editAccount(userToEdit, editDetail) {
const apiEdit = `/api/users/${userToEdit}`;
try{
const response = await this.$axios.put(apiEdit, {
username: editDetail.newUsername,
password: editDetail.password,
name: editDetail.name,
is_active: editDetail.is_active,
});
if(response.status === 200) {
return true;
}
}
catch(error) {
apiError(error, 'Failed to edit the account.');
return false;
};
},
/**
* Get user detail by unique username.
* @param {string} uniqueUsername