edit account and logout feature
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user