MCPcopy
hub / github.com/strongloop/loopback / tokenHandler

Function tokenHandler

common/models/user.js:276–288  ·  view source on GitHub ↗
(err, token)

Source from the content-addressed store, hash-verified

274 defaultError.code = 'LOGIN_FAILED';
275
276 function tokenHandler(err, token) {
277 if (err) return fn(err);
278 if (Array.isArray(include) ? include.indexOf('user') !== -1 : include === 'user') {
279 // NOTE(bajtos) We can't set token.user here:
280 // 1. token.user already exists, it's a function injected by
281 // "AccessToken belongsTo User" relation
282 // 2. ModelBaseClass.toJSON() ignores own properties, thus
283 // the value won't be included in the HTTP response
284 // See also loopback#161 and loopback#162
285 token.__data.user = user;
286 }
287 fn(err, token);
288 }
289
290 if (err) {
291 debug('An error is reported from User.findOne: %j', err);

Callers

nothing calls this directly

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…