Logout: invalidate the auth token after logging out.

master
Tom Hacohen 5 years ago
parent 5ae627b5bb
commit 28c3a8395b

@ -39,7 +39,7 @@ class SideMenu extends React.PureComponent<PropsTypeInner> {
}
public logout() {
store.dispatch(logout());
store.dispatch(logout(this.props.etesync!));
this.props.onCloseDrawerRequest();
}

@ -5,7 +5,7 @@ import { UserInfo } from 'etesync';
import { CredentialsData, EntriesType, SettingsType } from './';
export const { fetchCredentials, logout } = createActions({
export const { fetchCredentials } = createActions({
FETCH_CREDENTIALS: (username: string, password: string, server: string) => {
const authenticator = new EteSync.Authenticator(server);
@ -27,9 +27,23 @@ export const { fetchCredentials, logout } = createActions({
);
});
},
LOGOUT: () => undefined,
});
export const logout = createAction(
'LOGOUT',
(etesync: CredentialsData) => {
(async () => {
const authenticator = new EteSync.Authenticator(etesync.serviceApiUrl);
try {
await authenticator.invalidateToken(etesync.credentials.authToken);
} catch {
// Ignore for now. It usually means the token was a legacy one.
}
})();
return; // We are not waiting on the above on purpose for now, just invalidate the token in the background
}
);
export const { deriveKey } = createActions({
DERIVE_KEY: (username: string, encryptionPassword: string) => {
return EteSync.deriveKey(username, encryptionPassword);

Loading…
Cancel
Save