aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/settings/navigation/SettingsNavigation.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/settings/navigation/SettingsNavigation.js')
-rw-r--r--src/components/settings/navigation/SettingsNavigation.js52
1 files changed, 20 insertions, 32 deletions
diff --git a/src/components/settings/navigation/SettingsNavigation.js b/src/components/settings/navigation/SettingsNavigation.js
index 2fdb6e574..e8370d2ef 100644
--- a/src/components/settings/navigation/SettingsNavigation.js
+++ b/src/components/settings/navigation/SettingsNavigation.js
@@ -57,42 +57,34 @@ class SettingsNavigation extends Component {
57 workspaceCount: PropTypes.number.isRequired, 57 workspaceCount: PropTypes.number.isRequired,
58 }; 58 };
59 59
60 handleLoginLogout() { 60 handleLogout() {
61 const isLoggedIn = Boolean(localStorage.getItem('authToken'));
62 const isUsingWithoutAccount = 61 const isUsingWithoutAccount =
63 this.props.stores.settings.app.server === LOCAL_SERVER; 62 this.props.stores.settings.app.server === LOCAL_SERVER;
64 63
65 if (isLoggedIn) { 64 // Remove current auth token
66 // Remove current auth token 65 localStorage.removeItem('authToken');
67 localStorage.removeItem('authToken');
68 66
69 if (isUsingWithoutAccount) { 67 if (isUsingWithoutAccount) {
70 // Reset server back to Ferdi API 68 // Reset server back to Ferdi API
71 this.props.actions.settings.update({ 69 this.props.actions.settings.update({
72 type: 'app', 70 type: 'app',
73 data: { 71 data: {
74 server: LIVE_FERDI_API, 72 server: LIVE_FERDI_API,
75 }, 73 },
76 }); 74 });
77 }
78 this.props.stores.user.isLoggingOut = true;
79 } 75 }
76 this.props.stores.user.isLoggingOut = true;
80 77
81 this.props.stores.router.push( 78 this.props.stores.router.push('/auth/welcome');
82 isLoggedIn ? '/auth/logout' : '/auth/welcome',
83 );
84 79
85 if (isLoggedIn) { 80 // Reload Ferdi, otherwise many settings won't sync correctly with the server
86 // Reload Ferdi, otherwise many settings won't sync correctly with the server 81 // after logging into another account
87 // after logging into another account 82 window.location.reload();
88 window.location.reload();
89 }
90 } 83 }
91 84
92 render() { 85 render() {
93 const { serviceCount, workspaceCount, stores } = this.props; 86 const { serviceCount, workspaceCount, stores } = this.props;
94 const { intl } = this.props; 87 const { intl } = this.props;
95 const isLoggedIn = Boolean(localStorage.getItem('authToken'));
96 const isUsingWithoutAccount = stores.settings.app.server === LOCAL_SERVER; 88 const isUsingWithoutAccount = stores.settings.app.server === LOCAL_SERVER;
97 const isUsingFranzServer = stores.settings.app.server === LIVE_FRANZ_API; 89 const isUsingFranzServer = stores.settings.app.server === LIVE_FRANZ_API;
98 90
@@ -109,7 +101,6 @@ class SettingsNavigation extends Component {
109 to="/settings/services" 101 to="/settings/services"
110 className="settings-navigation__link" 102 className="settings-navigation__link"
111 activeClassName="is-active" 103 activeClassName="is-active"
112 disabled={!isLoggedIn}
113 > 104 >
114 {intl.formatMessage(messages.yourServices)}{' '} 105 {intl.formatMessage(messages.yourServices)}{' '}
115 <span className="badge">{serviceCount}</span> 106 <span className="badge">{serviceCount}</span>
@@ -118,7 +109,6 @@ class SettingsNavigation extends Component {
118 to="/settings/workspaces" 109 to="/settings/workspaces"
119 className="settings-navigation__link" 110 className="settings-navigation__link"
120 activeClassName="is-active" 111 activeClassName="is-active"
121 disabled={!isLoggedIn}
122 > 112 >
123 {intl.formatMessage(messages.yourWorkspaces)}{' '} 113 {intl.formatMessage(messages.yourWorkspaces)}{' '}
124 <span className="badge">{workspaceCount}</span> 114 <span className="badge">{workspaceCount}</span>
@@ -128,7 +118,6 @@ class SettingsNavigation extends Component {
128 to="/settings/user" 118 to="/settings/user"
129 className="settings-navigation__link" 119 className="settings-navigation__link"
130 activeClassName="is-active" 120 activeClassName="is-active"
131 disabled={!isLoggedIn}
132 > 121 >
133 {intl.formatMessage(messages.account)} 122 {intl.formatMessage(messages.account)}
134 </Link> 123 </Link>
@@ -138,7 +127,6 @@ class SettingsNavigation extends Component {
138 to="/settings/team" 127 to="/settings/team"
139 className="settings-navigation__link" 128 className="settings-navigation__link"
140 activeClassName="is-active" 129 activeClassName="is-active"
141 disabled={!isLoggedIn}
142 > 130 >
143 {intl.formatMessage(messages.team)} 131 {intl.formatMessage(messages.team)}
144 </Link> 132 </Link>
@@ -160,13 +148,13 @@ class SettingsNavigation extends Component {
160 <span className="settings-navigation__expander" /> 148 <span className="settings-navigation__expander" />
161 <button 149 <button
162 type="button" 150 type="button"
163 to={isLoggedIn ? '/auth/logout' : '/auth/welcome'} 151 to='/auth/logout'
164 className="settings-navigation__link" 152 className="settings-navigation__link"
165 onClick={this.handleLoginLogout.bind(this)} 153 onClick={this.handleLogout.bind(this)}
166 > 154 >
167 {isLoggedIn && !isUsingWithoutAccount 155 {!isUsingWithoutAccount
168 ? intl.formatMessage(messages.logout) 156 ? intl.formatMessage(messages.logout)
169 : 'Login'} 157 : 'Exit session'}
170 </button> 158 </button>
171 </div> 159 </div>
172 ); 160 );