-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathlesson2.js
More file actions
36 lines (29 loc) · 759 Bytes
/
lesson2.js
File metadata and controls
36 lines (29 loc) · 759 Bytes
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
// Permissions implementation does not matter
import { Permissions } from '@/lib/permissions'
// Check what should be tested
class User {
// NO
constructor(details, traits = {}) {
const { firstname, lastname } = details
this.firstname = firstname
this.lastname = lastname
this.traits = traits
this.sessionStartedAt = Date.now()
}
// YES
get name() {
return `${this.firstname} ${this.lastname}`
}
// YES
get isAdmin() {
return Permissions.granted(this, 'admin')
}
// YES in combination
get currentSessionIsValid() {
const tenMinutesInMiliseconds = 600000
return (this.sessionStartedAt + tenMinutesInMiliseconds) <= Date.now()
}
extendSession() {
this.sessionStartedAt = Date.now()
}
}