From 3be4d5f7d55e784cbb58018993144bc039302b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 8 Jun 2020 15:37:20 -0400 Subject: [PATCH] feat: redirect /me to user profile --- src/routes/accounts.js | 1 + test/controllers.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/routes/accounts.js b/src/routes/accounts.js index 0f44ab6938..bcdec1857e 100644 --- a/src/routes/accounts.js +++ b/src/routes/accounts.js @@ -7,6 +7,7 @@ module.exports = function (app, middleware, controllers) { var middlewares = [middleware.exposeUid, middleware.canViewUsers]; var accountMiddlewares = [middleware.exposeUid, middleware.canViewUsers, middleware.checkAccountPermissions]; + app.get('/me', middleware.redirectMeToUserslug); setupPageRoute(app, '/me/*', middleware, [], middleware.redirectMeToUserslug); setupPageRoute(app, '/uid/:uid*', middleware, [], middleware.redirectUidToUserslug); diff --git a/test/controllers.js b/test/controllers.js index dfb0d5384b..a6688da028 100644 --- a/test/controllers.js +++ b/test/controllers.js @@ -1070,6 +1070,15 @@ describe('Controllers', function () { }); describe('/me/*', function () { + it('should redirect to user profile', function (done) { + request(nconf.get('url') + '/me', { jar: jar, json: true }, function (err, res, body) { + assert.ifError(err); + assert.equal(res.statusCode, 200); + assert(body.includes('template: "account/profile"')); + assert(body.includes('"username":"foo"')); + done(); + }); + }); it('api should redirect to /user/[userslug]/bookmarks', function (done) { request(nconf.get('url') + '/api/me/bookmarks', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err);