Say goodbye to the user when he logs out

This commit is contained in:
Felix Hamme 2019-04-23 20:47:07 +02:00
parent b85ce62b2f
commit 7b38b503ef
2 changed files with 13 additions and 7 deletions

View File

@ -38,7 +38,7 @@ const actiontypes_userinfo = {
const defaultstate_userinfo = {
isSignedIn : false,
wasGreeted : false,
wasGreeted : true,
username : null,
error : false,
errorMessages : [],
@ -261,6 +261,7 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
case actiontypes_userinfo.CLEAR:
return Object.assign({}, state, {
isSignedIn : false,
wasGreeted : false,
username : null,
error : false,
errorMessages : [],

View File

@ -14,7 +14,7 @@ import { connect } from 'react-redux';
import React from 'react';
import {greet, logout} from '../api';
import {notify} from "react-notify-toast";
import {notify} from 'react-notify-toast';
export class TurniereNavigation extends React.Component {
@ -70,12 +70,12 @@ class InvisibleLoginLogoutButtons extends React.Component {
render() {
const {isSignedIn, username, wasGreeted} = this.props;
if (isSignedIn && !wasGreeted) {
notify.show('Willkommen, ' + username + '!', 'success', 3000);
greet();
}
if(isSignedIn) {
if (!wasGreeted) {
notify.show('Willkommen, ' + username + '!', 'success', 2500);
greet();
}
return (
<ButtonGroup className="nav-item">
<Button outline color="success" href="/profile" className="navbar-btn my-2 my-sm-0 px-5">{ username }</Button>
@ -83,6 +83,11 @@ class InvisibleLoginLogoutButtons extends React.Component {
</ButtonGroup>
);
} else {
if (!wasGreeted) {
notify.show('Du bist jetzt abgemeldet!', 'success', 2500);
greet();
}
return (
<ButtonGroup className="nav-item">
<Button outline color="success" href="/login" className="navbar-btn my-2 my-sm-0 px-5">Login</Button>