caccl-authorizer
Advanced tools
Comparing version 2.0.0-beta.16 to 2.0.0-beta.17
@@ -220,3 +220,3 @@ "use strict"; | ||
opts.app.get(CACCL_PATHS_1.default.AUTHORIZE, function (req, res, next) { return __awaiter(void 0, void 0, void 0, function () { | ||
var _a, launched, launchInfo, tokenPack, err_2, authURL; | ||
var _a, launched, launchInfo, tokenPack, err_2, devCreds, authURL; | ||
return __generator(this, function (_b) { | ||
@@ -255,3 +255,7 @@ switch (_b.label) { | ||
case 5: | ||
authURL = "https://".concat(launchInfo.canvasHost, "/login/oauth2/auth?client_id=").concat(opts.developerCredentials[launchInfo.canvasHost].clientId, "&response_type=code&redirect_uri=https://").concat(req.hostname).concat(CACCL_PATHS_1.default.AUTHORIZE, "&state=caccl").concat(scopesQueryAddon); | ||
devCreds = opts.developerCredentials[launchInfo.canvasHost]; | ||
if (!devCreds) { | ||
return [2 /*return*/, res.status(404).send('We could not authorize you with Canvas because this app is not prepared for use with this Canvas instance.')]; | ||
} | ||
authURL = "https://".concat(launchInfo.canvasHost, "/login/oauth2/auth?client_id=").concat(devCreds.clientId, "&response_type=code&redirect_uri=https://").concat(req.hostname).concat(CACCL_PATHS_1.default.AUTHORIZE, "&state=caccl").concat(scopesQueryAddon); | ||
return [2 /*return*/, res.redirect(authURL)]; | ||
@@ -258,0 +262,0 @@ } |
{ | ||
"name": "caccl-authorizer", | ||
"version": "2.0.0-beta.16", | ||
"version": "2.0.0-beta.17", | ||
"description": "Acquires Canvas tokens through via OAuth, stores refresh tokens, and refreshes access tokens when they expire.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -263,4 +263,10 @@ // Import express | ||
// Get developer credentials | ||
const devCreds = opts.developerCredentials[launchInfo.canvasHost]; | ||
if (!devCreds) { | ||
return res.status(404).send('We could not authorize you with Canvas because this app is not prepared for use with this Canvas instance.'); | ||
} | ||
// Refresh failed. Redirect to authorization process | ||
const authURL = `https://${launchInfo.canvasHost}/login/oauth2/auth?client_id=${opts.developerCredentials[launchInfo.canvasHost].clientId}&response_type=code&redirect_uri=https://${req.hostname}${CACCL_PATHS.AUTHORIZE}&state=caccl${scopesQueryAddon}`; | ||
const authURL = `https://${launchInfo.canvasHost}/login/oauth2/auth?client_id=${devCreds.clientId}&response_type=code&redirect_uri=https://${req.hostname}${CACCL_PATHS.AUTHORIZE}&state=caccl${scopesQueryAddon}`; | ||
return res.redirect(authURL); | ||
@@ -267,0 +273,0 @@ }, |
Sorry, the diff of this file is not supported yet
76067
1294