Migrated authentication.isSetup method to v2

This commit is contained in:
Nazar Gargol 2019-07-25 14:36:51 +02:00
parent 07782d8fa2
commit 4441ee15a0
3 changed files with 24 additions and 1 deletions

View File

@ -1,4 +1,5 @@
const api = require('./index');
const config = require('../../config');
const web = require('../../web');
const models = require('../../models');
const auth = require('../../services/auth');
@ -34,6 +35,22 @@ module.exports = {
}
},
isSetup: {
permissions: false,
query() {
return auth.setup.checkIsSetup()
.then((isSetup) => {
return {
status: isSetup,
// Pre-populate from config if, and only if the values exist in config.
title: config.title || undefined,
name: config.user_name || undefined,
email: config.user_email || undefined
};
});
}
},
generateResetToken: {
permissions: true,
options: [

View File

@ -11,6 +11,12 @@ module.exports = {
};
},
isSetup(data, apiConfig, frame) {
frame.response = {
setup: [data]
};
},
acceptInvitation(data, apiConfig, frame) {
debug('acceptInvitation');

View File

@ -191,7 +191,7 @@ module.exports = function apiRoutes() {
router.get('/authentication/invitation', api.http(apiv2.authentication.isInvitation));
router.post('/authentication/setup', api.http(apiv2.authentication.setup));
router.put('/authentication/setup', mw.authAdminApi, api.http(api.authentication.updateSetup));
router.get('/authentication/setup', api.http(api.authentication.isSetup));
router.get('/authentication/setup', api.http(apiv2.authentication.isSetup));
// ## Images
router.post('/images/upload',