Improves error message on bad config; refactors common code

Could you use `hasattr(request.session, 'LTI_LAUNCH')` here?  If that's doable, then I think you could collapse the lines above into one if statement and have a one-liner below to get the roles like `request.session['LTI_LAUNCH']['roles'].  Feel free to ignore the suggestion as it is just a style preference, but I thought I'd just offer up the possibility.