-
Notifications
You must be signed in to change notification settings - Fork 640
/
Copy pathuser.js
53 lines (44 loc) · 1.27 KB
/
user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import Model, { attr } from '@ember-data/model';
import { inject as service } from '@ember/service';
import { waitForPromise } from '@ember/test-waiters';
import { apiAction } from '@mainmatter/ember-api-actions';
export default class User extends Model {
@service store;
@attr email;
@attr email_verified;
@attr email_verification_sent;
@attr name;
@attr is_admin;
@attr login;
@attr username;
@attr avatar;
@attr url;
@attr kind;
@attr publish_notifications;
async stats() {
return await waitForPromise(apiAction(this, { method: 'GET', path: 'stats' }));
}
async changeEmail(email) {
await waitForPromise(apiAction(this, { method: 'PUT', data: { user: { email } } }));
this.store.pushPayload({
user: {
id: this.id,
email,
email_verified: false,
email_verification_sent: true,
},
});
}
async updatePublishNotifications(enabled) {
await waitForPromise(apiAction(this, { method: 'PUT', data: { user: { publish_notifications: enabled } } }));
this.store.pushPayload({
user: {
id: this.id,
publish_notifications: enabled,
},
});
}
async resendVerificationEmail() {
return await waitForPromise(apiAction(this, { method: 'PUT', path: 'resend' }));
}
}