Merge pull request #80 from lbryio/user-fix

add back user to state when calling doAuthenticate
This commit is contained in:
Jeremy Kauffman 2020-01-15 10:34:11 -05:00 committed by GitHub
commit 866a80a552
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 30 deletions

11
dist/bundle.es.js vendored
View file

@ -1299,17 +1299,19 @@ function doAuthenticate(appVersion, os = null, firebaseToken = null) {
dispatch({
type: AUTHENTICATION_STARTED
});
Lbryio.authenticate().then(accessToken => {
// analytics.setUser(user);
Lbryio.authenticate().then(user => {
Lbryio.getAuthToken().then(token => {
dispatch({
type: AUTHENTICATION_SUCCESS,
data: {
accessToken
user,
accessToken: token
}
});
dispatch(doRewardList());
dispatch(doFetchInviteStatus());
doInstallNew(appVersion, os, firebaseToken);
});
}).catch(error => {
dispatch({
type: AUTHENTICATION_FAILURE,
@ -2978,7 +2980,8 @@ reducers$2[AUTHENTICATION_STARTED] = state => Object.assign({}, state, {
reducers$2[AUTHENTICATION_SUCCESS] = (state, action) => Object.assign({}, state, {
authenticationIsPending: false,
userIsPending: false,
accessToken: action.data.accessToken
accessToken: action.data.accessToken,
user: action.data.user
});
reducers$2[AUTHENTICATION_FAILURE] = state => Object.assign({}, state, {

11
dist/bundle.js vendored
View file

@ -4926,17 +4926,19 @@ function doAuthenticate(appVersion) {
dispatch({
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["AUTHENTICATION_STARTED"]
});
lbryio__WEBPACK_IMPORTED_MODULE_5__["default"].authenticate().then(function (accessToken) {
// analytics.setUser(user);
lbryio__WEBPACK_IMPORTED_MODULE_5__["default"].authenticate().then(function (user) {
lbryio__WEBPACK_IMPORTED_MODULE_5__["default"].getAuthToken().then(function (token) {
dispatch({
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["AUTHENTICATION_SUCCESS"],
data: {
accessToken: accessToken
user: user,
accessToken: token
}
});
dispatch(Object(redux_actions_rewards__WEBPACK_IMPORTED_MODULE_2__["doRewardList"])());
dispatch(doFetchInviteStatus());
doInstallNew(appVersion, os, firebaseToken);
});
})["catch"](function (error) {
dispatch({
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["AUTHENTICATION_FAILURE"],
@ -6807,7 +6809,8 @@ reducers[constants_action_types__WEBPACK_IMPORTED_MODULE_0__["AUTHENTICATION_SUC
return Object.assign({}, state, {
authenticationIsPending: false,
userIsPending: false,
accessToken: action.data.accessToken
accessToken: action.data.accessToken,
user: action.data.user
});
};

View file

@ -175,6 +175,7 @@ Lbryio.authenticate = () => {
if (!user) {
return Lbryio.getCurrentUser();
}
return user;
})
.then(resolve, reject);

View file

@ -71,15 +71,17 @@ export function doAuthenticate(appVersion, os = null, firebaseToken = null) {
});
Lbryio.authenticate()
.then(accessToken => {
// analytics.setUser(user);
.then(user => {
Lbryio.getAuthToken().then(token => {
dispatch({
type: ACTIONS.AUTHENTICATION_SUCCESS,
data: { accessToken },
data: { user, accessToken: token },
});
dispatch(doRewardList());
dispatch(doFetchInviteStatus());
doInstallNew(appVersion, os, firebaseToken);
});
})
.catch(error => {
dispatch({

View file

@ -37,6 +37,7 @@ reducers[ACTIONS.AUTHENTICATION_SUCCESS] = (state, action) =>
authenticationIsPending: false,
userIsPending: false,
accessToken: action.data.accessToken,
user: action.data.user,
});
reducers[ACTIONS.AUTHENTICATION_FAILURE] = state =>