1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-04-11 11:12:03 +02:00

Desktop: Make sure clipper authorisation notification is displayed, even when in config screen

This commit is contained in:
Laurent Cozic 2021-07-19 09:46:32 +01:00
parent bddbc0b54e
commit b2de27b6fc
3 changed files with 15 additions and 1 deletions

View File

@ -40,6 +40,17 @@ class ClipperConfigScreenComponent extends React.Component {
alert(_('Token has been copied to the clipboard!'));
}
componentDidUpdate(prevProps) {
if (prevProps.needApiAuth !== this.props.needApiAuth && this.props.needApiAuth) {
// Ideally when API auth is needed, we should display the
// notification in this screen, however it's not setup for it yet.
// So instead, we just go back to the main screen where the
// notification will be displayed.
// https://discourse.joplinapp.org/t/web-clipper-2-1-3-not-working/18582/27
this.props.dispatch({ type: 'NAV_BACK' });
}
}
renewToken_click() {
if (confirm(_('Are you sure you want to renew the authorisation token?'))) {
void EncryptionService.instance()
@ -171,6 +182,7 @@ const mapStateToProps = state => {
clipperServer: state.clipperServer,
clipperServerAutoStart: state.settings['clipperServer.autoStart'],
apiToken: state.settings['api.token'],
needApiAuth: state.needApiAuth,
};
};

View File

@ -132,6 +132,8 @@ export default class Api {
}
public acceptAuthToken(accept: boolean) {
if (!this.authToken_) throw new Error('Auth token is not set');
this.authToken_.status = accept ? AuthTokenStatus.Accepted : AuthTokenStatus.Rejected;
this.dispatch_({

View File

@ -19,7 +19,7 @@ export default async function(request: Request, id: string = null, _link: string
if (request.method === 'GET') {
if (id === 'check') {
if ('auth_token' in request.query) {
if (request.query.auth_token === context.authToken.value) {
if (context.authToken && request.query.auth_token === context.authToken.value) {
const output: any = {
status: context.authToken.status,
};