Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Ensure scalar_token is valid before opening integrations manager #2777

Merged
merged 1 commit into from
Mar 13, 2019

Conversation

jaywink
Copy link
Member

@jaywink jaywink commented Mar 12, 2019

Since Scalar (and other integration managers) are loaded as apps into
an iframe, a valid scalar_token must exist when loading the app.

It is possible that a scalar_token becomes invalid between the time
when the integration manager button was rendered and the user clicking
the link. Here we make a call to integration manager /account
before trying to render the integration manager, which ensures we
have a valid token for the integration manager to work with.

Moving the scalar token revalidation to the cases where it is actually
needed could make it possible to decrease the amount of Scalar /account
calls we do when switching rooms, which is currently 3.

Signed-off-by: Jason Robinson jasonr@matrix.org

@jaywink jaywink requested review from rxl881 and a team March 12, 2019 13:01
Copy link
Contributor

@rxl881 rxl881 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks plausible to me (assuming it's tested and working).

@jryans jryans self-requested a review March 12, 2019 18:24
Copy link
Collaborator

@jryans jryans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few spacing issues we should fix before merging, but otherwise it looks good to me. 😁

Free free to fix and merge yourself when done.

null,
}, "mx_IntegrationsManager");
}, (err) => {
this.setState({ scalarError: err});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Please balance the spacing in this object

}, "mx_IntegrationsManager");
this.setState({showStickers: false});
}, (err) => {
this.setState({ imError: err});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Please balance the spacing in this object

Since Scalar (and other integration managers) are loaded as apps into
an iframe, a valid `scalar_token` must exist when loading the app.

It is possible that a scalar_token becomes invalid between the time
when the integration manager button was rendered and the user clicking
the link. Here we make a call to integration manager `/account`
before trying to render the integration manager, which ensures we
have a valid token for the integration manager to work with.

Moving the scalar token revalidation to the cases where it is actually
needed could make it possible to decrease the amount of Scalar /account
calls we do when switching rooms, which is currently 3.

Signed-off-by: Jason Robinson <jasonr@matrix.org>
@jaywink jaywink force-pushed the jaywink/ensure-scalar-token branch from 5f28cf9 to 02ff176 Compare March 13, 2019 09:47
@jaywink jaywink merged commit bc08065 into develop Mar 13, 2019
@jaywink jaywink deleted the jaywink/ensure-scalar-token branch March 13, 2019 10:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants