forked from panva/node-oidc-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount.js
59 lines (52 loc) · 1.33 KB
/
account.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
54
55
56
57
58
59
'use strict';
const store = new Map();
const logins = new Map();
const uuid = require('uuid');
class Account {
constructor(id) {
this.accountId = id || uuid();
store.set(this.accountId, this);
}
claims() {
return {
address: {
country: '000',
formatted: '000',
locality: '000',
postal_code: '000',
region: '000',
street_address: '000',
},
birthdate: '1987-10-16',
email: '[email protected]',
email_verified: false,
family_name: 'Doe',
gender: 'male',
given_name: 'John',
locale: 'en-US',
middle_name: 'Middle',
name: 'John Doe',
nickname: 'Johny',
phone_number: '+49 000 000000',
phone_number_verified: false,
picture: 'http://lorempixel.com/400/200/',
preferred_username: 'Jdawg',
profile: 'https://johnswebsite.com',
sub: this.accountId,
updated_at: 1454704946,
website: 'http://example.com',
zoneinfo: 'Europe/Berlin',
};
}
static findByLogin(login) {
if (!logins.get(login)) {
logins.set(login, new Account());
}
return Promise.resolve(logins.get(login));
}
static findById(id) {
if (!store.get(id)) new Account(id); // eslint-disable-line no-new
return Promise.resolve(store.get(id));
}
}
module.exports = Account;