1 |
/* Copyright (c) 2012-2020 Richard Rodger and other contributors, MIT License. */
|
1✔ |
2 |
'use strict'
|
1✔ |
3 | 1✔ | |
4 |
module.exports = ctx => { |
1✔ |
5 |
const intern = ctx.intern |
1✔ |
6 | 1✔ | |
7 |
return async function get_user(msg) { |
8✔ |
8 |
var seneca = this |
1✔ |
9 | 1✔ | |
10 |
// list verifications
|
1✔ |
11 |
var verification = !!msg.verification
|
23✔ |
12 | 1✔ | |
13 |
if (verification) {
|
23✔ |
14 |
msg = intern.load_user_fields(msg, 'verified')
|
1✔ |
15 |
} |
1✔ |
16 | 1✔ | |
17 |
var found = await intern.find_user(this, msg, ctx) |
23✔ |
18 | 1✔ | |
19 |
if (!found.ok) {
|
23✔ |
20 |
return found
|
3✔ |
21 |
} |
1✔ |
22 | 1✔ | |
23 |
if (verification) {
|
20✔ |
24 |
found.verification = { |
1✔ |
25 |
items: await seneca.entity(ctx.sys_verify).list$({ |
1✔ |
26 |
user_id: found.user.id
|
1✔ |
27 |
}) |
1✔ |
28 |
} |
1✔ |
29 |
} |
1✔ |
30 | 1✔ | |
31 |
return found
|
20✔ |
32 |
} |
1✔ |
33 |
} |
1✔ |