Refactored business logic provider

This commit is contained in:
maciekglowacki 2020-06-20 11:27:19 +02:00
parent 63c85abeb4
commit 9da1dfd51f
2 changed files with 11 additions and 3 deletions

View File

@ -30,17 +30,25 @@ class BusinessLogicProvider extends Component<Props, BusinessState> {
const ticket = urlParams.get("ticket");
if (!ticket) {
window.location.replace(`https://cas.amu.edu.pl/cas/login?service=${window.origin}&locale=pl`);
this.redirectToCASLoginService();
}
if (ticket && !this.state.user) {
if (ticket) {
this.setState({ user: { ticket } });
}
}
logout() {
this.redirectToCASLogoutService();
}
redirectToCASLogoutService() {
window.location.replace(`https://cas.amu.edu.pl/cas/logout?service=${window.origin}`);
}
redirectToCASLoginService() {
window.location.replace(`https://cas.amu.edu.pl/cas/login?service=${window.origin}&locale=pl`);
}
render() {
return (
<BusinessLogicContext.Provider

View File

@ -1,5 +1,5 @@
export type User = {
name?: string;
surname?: string;
ticket: string;
ticket: string | null;
};