From b037a107c44d312a9d30ddebd672b6f8d95832af Mon Sep 17 00:00:00 2001 From: Denis Barbaron Date: Tue, 13 Jun 2023 13:02:59 +0200 Subject: [PATCH] update oauth2 to get contact information (#673) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Denis barbaron Co-authored-by: Karol Wrótniak --- lib/units/auth/oauth2/index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/units/auth/oauth2/index.js b/lib/units/auth/oauth2/index.js index 30144d55..e758f608 100644 --- a/lib/units/auth/oauth2/index.js +++ b/lib/units/auth/oauth2/index.js @@ -8,6 +8,8 @@ var urlutil = require('../../../util/urlutil') var jwtutil = require('../../../util/jwtutil') var Strategy = require('./strategy') +const dbapi = require('../../../db/api') + module.exports = function(options) { var log = logger.createLogger('auth-oauth2') var app = express() @@ -16,6 +18,24 @@ module.exports = function(options) { app.set('strict routing', true) app.set('case sensitive routing', true) + app.get('/auth/contact', function(req, res) { + dbapi.getRootGroup().then(function(group) { + res.status(200) + .json({ + success: true + , contact: group.owner + }) + }) + .catch(function(err) { + log.error('Unexpected error', err.stack) + res.status(500) + .json({ + success: false + , error: 'ServerError' + }) + }) + }) + function verify(accessToken, refreshToken, profile, done) { done(null, profile) }