feature: admin role edit API
This commit is contained in:
@@ -147,6 +147,42 @@ export default defineStore('acctMgmtStore', {
|
||||
return false;
|
||||
};
|
||||
},
|
||||
/** Add a role to the user in database.
|
||||
* @param {string} usernameToEdit
|
||||
* @param {string} roleCode
|
||||
*/
|
||||
async addRoleToUser(usernameToEdit, roleCode) {
|
||||
const apiAddRole = `/api/users/${usernameToEdit}/roles/${roleCode}`;
|
||||
|
||||
try{
|
||||
const response = await this.$axios.put(apiAddRole);
|
||||
if(response.status === 200) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch(error) {
|
||||
apiError(error, 'Failed to add role to the account.');
|
||||
return false;
|
||||
};
|
||||
},
|
||||
/** Delete a role from the user in database.
|
||||
* @param {string} usernameToEdit
|
||||
* @param {string} roleCode
|
||||
*/
|
||||
async deleteRoleToUser(usernameToEdit, roleCode) {
|
||||
const apiDeleteRole = `/api/users/${usernameToEdit}/roles/${roleCode}`;
|
||||
|
||||
try{
|
||||
const response = await this.$axios.delete(apiDeleteRole);
|
||||
if(response.status === 200) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch(error) {
|
||||
apiError(error, 'Failed to delete a role frome the account.');
|
||||
return false;
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Get user detail by unique username.
|
||||
* @param {string} uniqueUsername
|
||||
|
||||
Reference in New Issue
Block a user