Skip to content
Open
11 changes: 11 additions & 0 deletions packages/selenium-ide/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import Router from '../router'
import apiv1 from './v1'
import Manager from '../plugin/manager'

const router = new Router()
router.use('/v1', apiv1)
Expand All @@ -26,6 +27,16 @@ export default function(message, _backgroundPage, sendResponse) {
// The sender is always the background page since he is the one listening to the event
// message.sender is the external extension id
if (message.uri) {
if (
message.uri !== '/health' &&
message.uri !== '/register' &&
!Manager.hasPlugin(message.payload.sender)
) {
return sendResponse({
error:
'Plugin is not registered with Selenium IDE, send a request to /register first',
})
}
router
.run(message)
.then(sendResponse)
Expand Down
2 changes: 1 addition & 1 deletion packages/selenium-ide/src/api/v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ router.get('/project', (_req, res) => {
})

router.post('/project', (req, res) => {
const plugin = Manager.getPlugin(req.sender)
if (req.project) {
const plugin = Manager.getPlugin(req.sender)
if (!UiState.isSaved()) {
ModalState.showAlert({
title: 'Open project without saving',
Expand Down