Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api plugin registration verification #813

Open
wants to merge 12 commits into
base: v3
Choose a base branch
from
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