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

Add a null check for authScopes variable #1261

Merged
merged 3 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ way to update this template, but currently, we follow a pattern:

- [add] Show a banner when a user is logged in with limited access.
[#1259](https://github.com/sharetribe/ftw-daily/pull/1259)
[#1261](https://github.com/sharetribe/ftw-daily/pull/1261)
- [add] Support for logging in as a user from Console.
[#1254](https://github.com/sharetribe/ftw-daily/pull/1254)
- [change] Add `handlebars` 4.5.3 and `serialize-javascript` 2.1.1 to resolutions in `package.json`.
Expand Down
12 changes: 6 additions & 6 deletions server/apiRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* tasks that can not be handled in the browser.
*
* The endpoints should not clash with the application routes. Therefore, the
* enpoints are prefixed in the main server where this file is used.
* endpoints are prefixed in the main server where this file is used.
*/

const http = require('http');
Expand All @@ -23,8 +23,8 @@ const USING_SSL = process.env.REACT_APP_SHARETRIBE_USING_SSL === 'true';

const router = express.Router();

// redirect_uri param used when initiating a login as authenitcation flow and
// when requesting a token useing an authorization code
// redirect_uri param used when initiating a login as authentication flow and
// when requesting a token using an authorization code
const loginAsRedirectUri = `${ROOT_URL.replace(/\/$/, '')}/api/login-as`;

// Instantiate HTTP(S) Agents with keepAlive set to true.
Expand All @@ -50,14 +50,14 @@ const urlifyBase64 = base64Str =>

// Initiates an authorization code authentication flow. This authentication flow
// enables marketplace operators that have an ongoing Console session to log
// into their marketplace as a user of the marketpalce.
// into their marketplace as a user of the marketplace.
//
// The authroization code is requested from Console and it is used to request a
// The authorization code is requested from Console and it is used to request a
// token from the Flex Auth API.
//
// This endpoint will return a 302 to Console which requests the authorization
// code. Console returns a 302 with the code to the `redirect_uri` that is
// passed in this reponse. The request to the redirect URI is handled with the
// passed in this response. The request to the redirect URI is handled with the
// `/login-as` endpoint.
router.get('/initiate-login-as', (req, res) => {
const userId = req.query.user_id;
Expand Down
1 change: 1 addition & 0 deletions src/components/LimitedAccessBanner/LimitedAccessBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const LimitedAccessBanner = props => {
const showBanner =
user.id &&
isAuthenticated &&
authScopes &&
authScopes.length === 1 &&
authScopes[0] === 'user:limited' &&
!disabledPages.includes(currentPage);
Expand Down