import React from 'react';
import {
withRouter
} from 'react-router-dom'
import { oauthLogoutApi } from '../../core/constants/AuthConstants';
import { Plugins } from '@capacitor/core';
import {
IonContent,
IonCol,
IonRow,
IonButton,
IonItem,
IonHeader,
IonPage,
IonImg, IonLabel, IonTabButton, IonIcon, IonText, IonRouterLink, IonFooter
} from '@ionic/react';
interface IProps {
history: any
}
interface IState {
}
/**
*
* Logout user from app
@category Category
*/
class Logout extends React.Component<IProps, IState>{
oauth2Options: any;
constructor(props: any) {
super(props);
}
/**
* Logout user from the app. Redirects to Login screen
*/
componentDidMount()
{
this.oauth2Options = oauthLogoutApi;
Plugins.OAuth2Client.authenticate(
this.oauth2Options
).then((response: any) => {
console.log(response);
}).catch((reason: any) => {
console.error("OAuth rejected", reason);
this.props.history.push({
pathname: '/',
})
localStorage.clear();
});
this.props.history.push({
pathname: '/Login',
})
localStorage.clear();
window.location.reload();
}
render()
{
return(
<IonPage>
<IonContent>
<IonItem>Session Invalidated</IonItem>
</IonContent>
</IonPage>
)
}
}
export default Logout;
Source