2014-07-11 23:01:42 +04:00
|
|
|
import ValidationEngine from 'ghost/mixins/validation-engine';
|
2014-07-06 00:44:19 +04:00
|
|
|
import NProgressSaveMixin from 'ghost/mixins/nprogress-save';
|
2014-07-11 23:01:42 +04:00
|
|
|
|
2014-07-06 00:44:19 +04:00
|
|
|
var User = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
|
2014-07-11 23:01:42 +04:00
|
|
|
validationType: 'user',
|
2014-05-09 09:00:10 +04:00
|
|
|
uuid: DS.attr('string'),
|
|
|
|
name: DS.attr('string'),
|
|
|
|
slug: DS.attr('string'),
|
|
|
|
password: DS.attr('string'),
|
|
|
|
email: DS.attr('string'),
|
|
|
|
image: DS.attr('string'),
|
|
|
|
cover: DS.attr('string'),
|
|
|
|
bio: DS.attr('string'),
|
|
|
|
website: DS.attr('string'),
|
|
|
|
location: DS.attr('string'),
|
|
|
|
accessibility: DS.attr('string'),
|
|
|
|
status: DS.attr('string'),
|
2014-07-05 12:06:10 +04:00
|
|
|
language: DS.attr('string', {defaultValue: 'en_US'}),
|
2014-05-09 09:00:10 +04:00
|
|
|
meta_title: DS.attr('string'),
|
|
|
|
meta_description: DS.attr('string'),
|
2014-06-05 20:04:59 +04:00
|
|
|
last_login: DS.attr('moment-date'),
|
|
|
|
created_at: DS.attr('moment-date'),
|
2014-05-09 09:00:10 +04:00
|
|
|
created_by: DS.attr('number'),
|
2014-06-05 20:04:59 +04:00
|
|
|
updated_at: DS.attr('moment-date'),
|
2014-05-09 09:00:10 +04:00
|
|
|
updated_by: DS.attr('number'),
|
2014-05-15 03:36:13 +04:00
|
|
|
|
2014-03-23 06:31:45 +04:00
|
|
|
saveNewPassword: function (password) {
|
2014-05-09 09:00:10 +04:00
|
|
|
var url = this.get('ghostPaths').adminUrl('changepw');
|
|
|
|
return ic.ajax.request(url, {
|
2014-03-23 06:31:45 +04:00
|
|
|
type: 'POST',
|
|
|
|
data: password
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-07-08 09:24:07 +04:00
|
|
|
resendInvite: function () {
|
|
|
|
var userData = {};
|
|
|
|
|
|
|
|
userData.email = this.get('email');
|
|
|
|
|
|
|
|
return ic.ajax.request(this.get('ghostPaths').apiUrl('users'), {
|
|
|
|
type: 'POST',
|
|
|
|
data: JSON.stringify({users: [userData]}),
|
|
|
|
contentType: 'application/json'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-05-09 09:00:10 +04:00
|
|
|
passwordValidationErrors: function (password) {
|
2014-03-23 06:31:45 +04:00
|
|
|
var validationErrors = [];
|
|
|
|
|
2014-03-31 13:57:50 +04:00
|
|
|
if (!validator.equals(password.newPassword, password.ne2Password)) {
|
2014-06-02 00:53:16 +04:00
|
|
|
validationErrors.push('Your new passwords do not match');
|
2014-03-23 06:31:45 +04:00
|
|
|
}
|
|
|
|
|
2014-03-31 13:57:50 +04:00
|
|
|
if (!validator.isLength(password.newPassword, 8)) {
|
2014-06-02 00:53:16 +04:00
|
|
|
validationErrors.push('Your password is not long enough. It must be at least 8 characters long.');
|
2014-03-23 06:31:45 +04:00
|
|
|
}
|
|
|
|
|
2014-05-09 09:00:10 +04:00
|
|
|
return validationErrors;
|
2014-07-11 23:01:42 +04:00
|
|
|
}
|
2014-06-27 23:08:16 +04:00
|
|
|
|
2014-03-23 06:31:45 +04:00
|
|
|
});
|
2013-08-05 21:26:44 +04:00
|
|
|
|
2014-05-09 09:00:10 +04:00
|
|
|
export default User;
|