-export const SSH_KEY_CREATE_FORM_NAME = 'sshKeyCreateFormName';
-export const SSH_KEY_PUBLIC_KEY_DIALOG = 'sshKeyPublicKeyDialog';
-export const SSH_KEY_REMOVE_DIALOG = 'sshKeyRemoveDialog';
-export const SSH_KEY_ATTRIBUTES_DIALOG = 'sshKeyAttributesDialog';
-
-export interface SshKeyCreateFormDialogData {
- publicKey: string;
- name: string;
-}
-
-function setAuthorizationHeader(services: ServiceRepository, token: string) {
- services.apiClient.defaults.headers.common = {
- Authorization: `OAuth2 ${token}`
- };
- services.webdavClient.defaults.headers = {
- Authorization: `OAuth2 ${token}`
- };
-}
-
-function removeAuthorizationHeader(client: AxiosInstance) {
- delete client.defaults.headers.common.Authorization;
-}
-
-export const initAuth = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const user = services.authService.getUser();
- const token = services.authService.getApiToken();
- if (token) {
- setAuthorizationHeader(services, token);
- }
- if (token && user) {
- dispatch(authActions.INIT({ user, token }));
+export const initAuth = (config: Config) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
+ // Cancel any link account ops in progress unless the user has
+ // just logged in or there has been a successful link operation
+ const data = services.linkAccountService.getLinkOpStatus();
+ if (!matchTokenRoute(window.location.pathname) &&
+ (!matchFedTokenRoute(window.location.pathname)) && data === undefined) {
+ await dispatch<any>(cancelLinking());