Removes the loadingWithAnonymousAccount function and handling, since the login happens before already and therefore the branch was never accessed anyway (dead-code) see fixme
*/
import Immutable from "immutable";
-import won from "../won-es6.js";
import { actionTypes, actionCreators } from "./actions.js";
import { getPostUriFromRoute } from "../selectors/general-selectors.js";
import { checkAccessToCurrentRoute } from "../configRouting.js";
-import { stateGoCurrent } from "./cstm-router-actions.js";
-
-import {
- checkLoginStatus,
- privateId2Credentials,
- login,
-} from "../won-utils.js";
-
-import { getParameterByName } from "../utils.js";
+import { checkLoginStatus } from "../won-utils.js";
import {
fetchOwnedData,
@@ -43,21 +34,7 @@ export const pageLoadAction = () => (dispatch, getState) => {
return loadingWhileSignedIn(dispatch, getState, data);
})
.catch(() => {
- //FIXME: I am actually not sure if we need that part here besides the else i feel like the loading of an anonymous account is being done before this already
- // as this is one of the first action-creators to be executed, we need to get the param directly from the url-bar instead of `state.getIn(['router','currentParams','privateId'])`
- const privateId =
- getParameterByName("privateId") || localStorage.getItem("privateId");
-
- if (privateId) {
- return loadingWithAnonymousAccount(dispatch, getState, privateId).catch(
- () => loadingWhileSignedOut(dispatch, getState)
- );
- } else {
- /*
- * ok, we're really not logged in -- thus we need to fetch any publicly visible, required data
- */
return loadingWhileSignedOut(dispatch, getState);
- }
});
};
@@ -70,48 +47,6 @@ function loadingWhileSignedIn(dispatch, getState, data) {
);
}
-function loadingWithAnonymousAccount(dispatch, getState, privateId) {
- // using an anonymous account. need to log in.
- const { email } = privateId2Credentials(privateId);
- return (
- login({ privateId })
- /* quickly dispatch log-in status, even before loading data, to
- * allow making correct access-control decisions
- */
- .then(response => {
- loginSuccess(email, true, dispatch, getState);
- return response;
- })
- .then(() => fetchOwnedData(email, dispatch))
- .then(() => {
- return dispatch({
- type: actionTypes.initialLoadFinished,
- });
- })
- .catch(e => {
- console.error(
- "failed to sign-in with privateId ",
- privateId,
- " because of: ",
- e
- );
- dispatch({
- type: actionTypes.account.loginFailed,
- payload: {
- loginError: Immutable.fromJS(won.PRIVATEID_NOT_FOUND_ERROR),
- credentials: { privateId },
- },
- });
- throw e;
- })
- .then(() => {
- dispatch(stateGoCurrent({ privateId }));
- })
- );
- //dispatch(actionCreators.login(email, password));
- //return; // the login action should fetch the required data, so we're done here.
-}
-
function loginSuccess(username, loginStatus, dispatch, getState) {
// reset websocket to make sure it's using the logged-in session
dispatch(actionCreators.reconnect__start());
