Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async (user) => {
const provider = 'google'
const { id_token: token } = user.getAuthResponse()
const result = defer()
mutex.claim(MUTEX_REQUEST)
try {
dispatch(actions.signIn({ provider, token }, result.resolver))
await result.promise
} catch (e) {
if (e instanceof errors.SSOUserNotFound) {
if (cfg.ssoAuth === true) {
dispatch(push(urls.ssoSignUp({ provider, token, next })))
// dont release mutex on redirect
return
}
notify(intl.formatMessage(msg.ssoGoogleNotFound))
} else {
notify(intl.formatMessage(msg.ssoGoogleErrorUnexpected))
sentry('captureException', e)
}
mutex.release(MUTEX_REQUEST)
}
},
[dispatch, mutex.claim, mutex.release, sentry, notify],
(evt) => {
// eslint-disable-next-line default-case
switch (evt.key) {
case 'Enter':
dispatch(push(urls.search({ q: value })))
break
case 'Escape':
evt.target.blur()
break
}
},
[dispatch, urls, value],
(evt) => {
// eslint-disable-next-line default-case
switch (evt.key) {
case 'Enter':
/* suppress onSubmit (didn't actually find this to be a problem tho) */
evt.preventDefault()
if (query !== value) {
dispatch(push(makeUrl(value)))
}
evt.target.blur()
break
case 'Escape':
evt.target.blur()
break
}
},
[dispatch, makeUrl, value, query],
(to) => {
if (to && currentBucket !== to) {
dispatch(push(urls.bucketRoot(to)))
}
if (cancel) cancel()
},
[currentBucket, urls, dispatch, cancel],
(newQuery) => {
dispatch(
push(urls.search({ q: newQuery, buckets: buckets.join(',') || undefined })),
)
},
[buckets, dispatch],