diff --git a/es/components/oauth/index.js b/es/components/oauth/index.js index 98c986732..00fc1d68a 100644 --- a/es/components/oauth/index.js +++ b/es/components/oauth/index.js @@ -1,4 +1,3 @@ -import assert from "assert"; export default OakComponent({ // Virtual Component isList: false, @@ -25,8 +24,16 @@ export default OakComponent({ this.setState({ loading: false }); return; } - assert(state, 'State parameter is missing'); - assert(code, 'Code parameter is missing'); + if (!code) { + this.setErrorMsg('Missing authorization code'); + this.setState({ loading: false }); + return; + } + if (!state) { + this.setErrorMsg('Missing state parameter'); + this.setState({ loading: false }); + return; + } this.setState({ hasError: false, errorMessage: '' }); if (!state) { this.setErrorMsg('Invalid state parameter'); diff --git a/src/components/oauth/index.ts b/src/components/oauth/index.ts index 92039ca47..aef6742c1 100644 --- a/src/components/oauth/index.ts +++ b/src/components/oauth/index.ts @@ -32,8 +32,17 @@ export default OakComponent({ return; } - assert(state, 'State parameter is missing'); - assert(code, 'Code parameter is missing'); + if (!code) { + this.setErrorMsg('Missing authorization code'); + this.setState({ loading: false }); + return; + } + + if (!state) { + this.setErrorMsg('Missing state parameter'); + this.setState({ loading: false }); + return; + } this.setState({ hasError: false, errorMessage: '' });