Skip to content

V5.9.5 - Improvements to dynamic registration

Latest
Compare
Choose a tag to compare
@Cvmcosta Cvmcosta released this 01 May 16:24
· 14 commits to master since this release

A few improvements to dynamic registration:

  • Fixed the regular LTI launch message type. This was not causing any issues, as the regular launch is always implied when performing dynamic registration.
  • Added ability to modify dynamic registration options when creating a custom handler. Thank you @pfgray for the contribution!

The following example is a representation of the default Dynamic Registration flow with overriden custom parameters:

lti.onDynamicRegistration(async (req, res, next) => {
  try {
    if (!req.query.openid_configuration) return res.status(400).send({ status: 400, error: 'Bad Request', details: { message: 'Missing parameter: "openid_configuration".' } })
    const message = await lti.DynamicRegistration.register(req.query.openid_configuration, req.query.registration_token, {
      'https://purl.imsglobal.org/spec/lti-tool-configuration': {
        custom_parameters: {
          'custom1': 'value1',
          'custom2': 'value2'
        }
      }
    })
    res.setHeader('Content-type', 'text/html')
    res.send(message)
  } catch (err) {
    if (err.message === 'PLATFORM_ALREADY_REGISTERED') return res.status(403).send({ status: 403, error: 'Forbidden', details: { message: 'Platform already registered.' } })
    return res.status(500).send({ status: 500, error: 'Internal Server Error', details: { message: err.message } })
  }
})