2020-04-14 11:13:45 +00:00
|
|
|
import RestModel from "model/rest";
|
2019-05-09 04:48:10 +00:00
|
|
|
import Form from "common/form";
|
|
|
|
import Api from "common/api";
|
2018-07-27 15:31:39 +00:00
|
|
|
|
2020-04-14 11:13:45 +00:00
|
|
|
class User extends RestModel {
|
2020-01-23 23:45:59 +00:00
|
|
|
getDefaults() {
|
|
|
|
return {
|
|
|
|
ID: 0,
|
|
|
|
FirstName: "",
|
|
|
|
LastName: "",
|
2020-01-31 14:29:06 +00:00
|
|
|
};
|
2020-01-23 23:45:59 +00:00
|
|
|
}
|
|
|
|
|
2018-07-27 15:31:39 +00:00
|
|
|
getEntityName() {
|
2019-11-08 05:53:40 +00:00
|
|
|
return this.FirstName + " " + this.LastName;
|
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;
|