Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 782003f

Browse files
author
ykohata
committed
Merge branch 'technology-2014-11-13'
2 parents 4e066e5 + de8c1f4 commit 782003f

File tree

4 files changed

+99
-3
lines changed

4 files changed

+99
-3
lines changed

actions/user.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var async = require('async');
1313
var _ = require('underscore');
1414
var BadRequestError = require('../errors/BadRequestError');
1515
var ForbiddenError = require('../errors/ForbiddenError');
16+
var NotFoundError = require('../errors/NotFoundError');
1617
var UnauthorizedError = require('../errors/UnauthorizedError');
1718
var IllegalArgumentError = require('../errors/IllegalArgumentError');
1819

@@ -322,3 +323,98 @@ exports.getUserIdentity = {
322323
}
323324
}
324325
};
326+
327+
/**
328+
* Get user identity information api.
329+
* @param {Object} api - The api object.
330+
* @param {Object} connection - The database connection map object.
331+
* @param {Function} next - The callback function.
332+
* @since 1.2
333+
*/
334+
function getUserIdentityByAuth0Id(api, connection, next) {
335+
var helper = api.helper,
336+
auth0id = connection.params.id,
337+
userid = 0,
338+
dbConnectionMap = connection.dbConnectionMap,
339+
notfound = new NotFoundError('Feelin lucky, punk?'),
340+
response;
341+
342+
async.waterfall([
343+
function (cb) {
344+
try {
345+
var splits = auth0id.split('|');
346+
if (splits[0] == 'ad') {
347+
cb(null, [{ user_id: Number(splits[1]) }]);
348+
} else {
349+
api.helper.getProviderId(splits[0], function(err, provider) {
350+
if (err) {
351+
cb(notfound);
352+
} else {
353+
api.dataAccess.executeQuery("get_user_by_social_login",
354+
{
355+
social_user_id: splits[1],
356+
provider_id: provider
357+
},
358+
dbConnectionMap, cb);
359+
}
360+
});
361+
}
362+
}
363+
catch (exc) {
364+
cb(notfound);
365+
}
366+
},
367+
function (result, cb) {
368+
userid = result[0].user_id
369+
api.dataAccess.executeQuery('get_user_email_and_handle',
370+
{ userId: userid },
371+
dbConnectionMap, cb);
372+
},
373+
function (rs, cb) {
374+
if (!rs[0]) {
375+
cb(notfound);
376+
} else {
377+
response = {
378+
uid: userid,
379+
handle: rs[0].handle
380+
};
381+
cb();
382+
}
383+
}
384+
], function (err) {
385+
if (err) {
386+
helper.handleError(api, connection, err);
387+
} else {
388+
connection.response = response;
389+
}
390+
next(connection, true);
391+
});
392+
393+
}
394+
395+
/**
396+
* The API for activate user
397+
* @since 1.2
398+
*/
399+
exports.getUserIdentityByAuth0Id = {
400+
name: 'getUserIdentityByAuth0Id',
401+
description: 'Get user identity information',
402+
inputs: {
403+
required: ['id'],
404+
optional: []
405+
},
406+
blockedConnectionTypes: [],
407+
outputExample: {},
408+
version: 'v2',
409+
transaction: 'read',
410+
databases: ['common_oltp'],
411+
cacheEnabled: false,
412+
run: function (api, connection, next) {
413+
if (connection.dbConnectionMap) {
414+
api.log('getUserIdentityByAuth0Id#run', 'debug');
415+
getUserIdentityByAuth0Id(api, connection, next);
416+
} else {
417+
api.helper.handleNoConnection(api, connection, next);
418+
}
419+
}
420+
};

apiary.apib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,7 @@ Request
23122312
+ Response 200 (application/json)
23132313

23142314
{
2315-
"uid": "uid=132456, ou=members, dc=topcoder, dc=com",
2315+
"uid": "132456",
23162316
"handle": "heffan",
23172317
"email": "foo@fooonyou.com"
23182318
}

queries/active_data_science_challenges

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ FROM
1111
active_data_science_challenges
1212
WHERE
1313
submission_end_date BETWEEN TO_DATE('@submitByFrom@ 00:00:00', '%Y-%m-%d %H:%M:%S') AND TO_DATE('@submitByTo@ 23:59:59', '%Y-%m-%d %H:%M:%S')
14-
AND CURRENT BETWEEN registration_start_date AND submission_end_date
15-
ORDER BY challenge_id
14+
ORDER BY challenge_id

routes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ exports.routes = {
256256

257257
{ path: "/:apiVersion/user/challenges", action: "getMyChallenges" },
258258
{ path: "/:apiVersion/user/activation-email", action: "userActivationEmail" },
259+
{ path: "/:apiVersion/user/tcid/:id", action: "getUserIdentityByAuth0Id" },
259260
{ path: "/:apiVersion/user/identity", action: "getUserIdentity" },
260261

261262
{ path: "/:apiVersion/users/tops/:trackType", action: "getTopTrackMembers" },

0 commit comments

Comments
 (0)