a7122ff4e1
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
import RestModel from "model/rest";
|
|
import Form from "common/form";
|
|
import Api from "common/api";
|
|
|
|
export class User extends RestModel {
|
|
getDefaults() {
|
|
return {
|
|
ID: 0,
|
|
FirstName: "",
|
|
LastName: "",
|
|
};
|
|
}
|
|
|
|
getEntityName() {
|
|
return this.FirstName + " " + this.LastName;
|
|
}
|
|
|
|
getId() {
|
|
return this.ID;
|
|
}
|
|
|
|
getRegisterForm() {
|
|
return Api.options(this.getEntityResource() + "/register").then(response => Promise.resolve(new Form(response.data)));
|
|
}
|
|
|
|
getProfileForm() {
|
|
return Api.options(this.getEntityResource() + "/profile").then(response => Promise.resolve(new Form(response.data)));
|
|
}
|
|
|
|
changePassword(oldPassword, newPassword) {
|
|
return Api.put(this.getEntityResource() + "/password", {
|
|
password: oldPassword,
|
|
new_password: newPassword,
|
|
}).then((response) => Promise.resolve(response.data));
|
|
}
|
|
|
|
saveProfile() {
|
|
return Api.post(this.getEntityResource() + "/profile", this.getValues()).then((response) => Promise.resolve(this.setValues(response.data)));
|
|
}
|
|
|
|
static getCollectionResource() {
|
|
return "users";
|
|
}
|
|
|
|
static getModelName() {
|
|
return "User";
|
|
}
|
|
}
|
|
|
|
export default User;
|