Skip to content

Commit

Permalink
Invites: fix logged in and logged out flows
Browse files Browse the repository at this point in the history
  • Loading branch information
lezama committed Dec 4, 2015
1 parent 66f8749 commit b0cca40
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/lib/invites/stores/invite-accepted.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const InviteMessageStore = createReducerStore( ( state, payload ) => {
switch ( action.type ) {
case ActionTypes.DISPLAY_INVITE_ACCEPTED_NOTICE:
newState.accepted = true;
newState.siteId = action.invite.site.ID;
newState.siteId = action.siteId;
return newState;
case ActionTypes.DISPLAY_INVITE_DECLINED_NOTICE:
newState.declined = true;
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/invites/invite-accept-logged-in/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default React.createClass( {

accept() {
this.setState( { submitting: true } );
acceptInvite( this.props.invite, () => page( this.props.redirectTo ) );
acceptInvite( this.props, () => page( this.props.redirectTo ) );
},

render() {
Expand Down
10 changes: 5 additions & 5 deletions client/my-sites/invites/invite-accept-logged-out/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default React.createClass( {
( error, bearerToken ) =>
bearerToken &&
acceptInvite(
this.props.invite,
this.props,
( acceptInviteError ) => this.setState( { acceptInviteError, userData, bearerToken } ),
bearerToken
)
Expand All @@ -54,20 +54,20 @@ export default React.createClass( {
<WpcomLoginForm
log={ userData.username }
authorization={ 'Bearer ' + bearerToken }
redirectTo={ window.location.origin + this.props.redirectTo + '?invite_accepted=' + this.props.invite.blog_id }
redirectTo={ window.location.origin + this.props.redirectTo + '?invite_accepted=' + this.props.site.ID }
/>
)
},

subscribeUserByEmailOnly() {
this.setState( { submitting: true } );
acceptInvite(
this.props.invite,
this.props,
( error ) => {
if ( error ) {
this.setState( { error } );
} else {
window.location = 'https://subscribe.wordpress.com?update=activate&email=' + encodeURIComponent( this.props.invite.meta.sent_to ) + '&key=' + this.props.invite.authKey;
window.location = 'https://subscribe.wordpress.com?update=activate&email=' + encodeURIComponent( this.props.sent_to ) + '&key=' + this.props.authKey;
}
}
);
Expand All @@ -86,7 +86,7 @@ export default React.createClass( {
},

renderEmailOnlySubscriptionLink() {
if ( this.props.invite.meta.role !== 'follower' || ! this.props.invite.activationKey ) {
if ( this.props.role !== 'follower' || ! this.props.activationKey ) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion shared/lib/wpcom-undocumented/lib/undocumented.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Undocumented.prototype.getInvite = function( siteId, inviteKey, fn ) {

Undocumented.prototype.acceptInvite = function( invite, fn ) {
debug( '/sites/:site_id:/invites/:inviteKey:/accept query' );
this.wpcom.req.get( '/sites/' + invite.blog_id + '/invites/' + invite.invite_slug + '/accept', {
this.wpcom.req.get( '/sites/' + invite.site.ID + '/invites/' + invite.inviteKey + '/accept', {
activate: invite.activationKey
}, fn );
};
Expand Down

0 comments on commit b0cca40

Please sign in to comment.