Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 1x 1x 1x 4x 4x 2x 2x 1x 1x 4x 1x 1x | import * as React from 'react'
import { User, UserManager } from 'oidc-client'
export interface ICallbackHandlers {
onSuccess?: (user: User) => void
onError?: (err: any) => void
}
export interface IRedirectCallback {
redirectCallback:
| UserManager['signinRedirectCallback']
| UserManager['signoutRedirectCallback']
}
export type ICallbackProps = ICallbackHandlers & IRedirectCallback
export type ICallbackActionProps = ICallbackHandlers & {
userManager: UserManager
}
class Callback extends React.Component<ICallbackProps> {
public componentDidMount() {
const { onSuccess, onError, redirectCallback } = this.props
redirectCallback()
.then(user => {
Iif (onSuccess) {
onSuccess(user)
}
})
.catch(err => {
if (onError) {
onError(err)
}
})
}
public render() {
return this.props.children || null
}
}
export default Callback
|