2018-07-27 15:31:39 +00:00
|
|
|
import Abstract from 'model/abstract';
|
|
|
|
import Form from 'common/form';
|
|
|
|
import Api from 'common/api';
|
|
|
|
|
|
|
|
class User extends Abstract {
|
|
|
|
getEntityName() {
|
|
|
|
return this.userFirstName + ' ' + this.userLastName;
|
|
|
|
}
|
|
|
|
|
|
|
|
getId() {
|
|
|
|
return this.userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
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() {
|
|
|
|
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;
|