2019-05-09 04:48:10 +00:00
|
|
|
import Abstract from "model/abstract";
|
|
|
|
import Form from "common/form";
|
|
|
|
import Api from "common/api";
|
2018-07-27 15:31:39 +00:00
|
|
|
|
|
|
|
class User extends Abstract {
|
|
|
|
getEntityName() {
|
2019-05-09 04:48:10 +00:00
|
|
|
return this.userFirstName + " " + this.userLastName;
|
2018-07-27 15:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getId() {
|
2019-05-21 09:54:39 +00:00
|
|
|
return this.ID;
|
2018-07-27 15:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getRegisterForm() {
|
2019-05-09 04:48:10 +00:00
|
|
|
return Api.options(this.getEntityResource() + "/register").then(response => Promise.resolve(new Form(response.data)));
|
2018-07-27 15:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getProfileForm() {
|
2019-05-09 04:48:10 +00:00
|
|
|
return Api.options(this.getEntityResource() + "/profile").then(response => Promise.resolve(new Form(response.data)));
|
2018-07-27 15:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
changePassword(oldPassword, newPassword) {
|
2019-05-09 04:48:10 +00:00
|
|
|
return Api.put(this.getEntityResource() + "/password", {
|
2018-07-27 15:31:39 +00:00
|
|
|
password: oldPassword,
|
2019-05-09 04:18:22 +00:00
|
|
|
new_password: newPassword,
|
2018-07-27 15:31:39 +00:00
|
|
|
}).then((response) => Promise.resolve(response.data));
|
|
|
|
}
|
|
|
|
|
|
|
|
saveProfile() {
|
2019-05-09 04:48:10 +00:00
|
|
|
return Api.post(this.getEntityResource() + "/profile", this.getValues()).then((response) => Promise.resolve(this.setValues(response.data)));
|
2018-07-27 15:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static getCollectionResource() {
|
2019-05-09 04:48:10 +00:00
|
|
|
return "users";
|
2018-07-27 15:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static getModelName() {
|
2019-05-09 04:48:10 +00:00
|
|
|
return "User";
|
2018-07-27 15:31:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default User;
|