Skip to content

Commit

Permalink
fixed recovery domain to be supportive of custom domains
Browse files Browse the repository at this point in the history
  • Loading branch information
ynnelson committed Jan 8, 2023
1 parent 2c58a91 commit 8fd1d71
Show file tree
Hide file tree
Showing 10 changed files with 523 additions and 251 deletions.
14 changes: 8 additions & 6 deletions app/login_window/routes/recovery/Recovery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ const Recovery = () => {
value: true,
message: 'Required field.'
},
pattern: {
value: externalEmailRE,
message: 'Invalid email address'
},
custom: {
isValid: async (value, data) => {
const val = `${value}@${mailDomain}`;
const mailboxes = await mailbox.getMailboxPubKeys([val]);
if (mailboxes[val]) {
// const val = `${value}@${mailDomain}`;
const mailboxes = await mailbox.getMailboxPubKeys([value]);
if (mailboxes[value]) {
return true;
}
return false;
Expand Down Expand Up @@ -159,9 +163,7 @@ const Recovery = () => {
value={data.accountEmail}
error={errors.accountEmail}
onChange={handleAccountChange}
addonPosition="right"
addonLabel={`@${mailDomain}`}
className="text-right"
activityPosition="right"
isValid={
errors.accountEmail === '' || errors.accountEmail === undefined
}
Expand Down
13 changes: 7 additions & 6 deletions app/main_window/actions/account/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export const updatePlan = (payload: { accountId: string; plan: string }) => {
};
};


/*
* This action is to retrieve the Account stats from the server and store them locally for use in the Settings Page.
*/
Expand Down Expand Up @@ -183,8 +182,7 @@ export const retrieveStats = () => {
result = await AccountService.retrieveStats();
if (plan !== result.plan) {
dispatch(updatePlan({ accountId, plan: result.plan }));
};

}
} catch (error) {
dispatch(retrieveStatsFailure(error));
return {
Expand Down Expand Up @@ -232,13 +230,16 @@ export const updateAccountPasswordFailure = (error: Error) => {
export const updateAccountPassword = (payload: {
email: string;
newPass: string;
mailboxId: string;
}) => {
return async (dispatch: Dispatch) => {
dispatch(updateAccountPasswordRequest(payload));
let result;

try {
const results = await AccountService.updateAccountPassword(payload);
await AccountService.updateAccountPassword({
email: payload.email,
newPass: payload.newPass
});
} catch (error) {
dispatch(updateAccountPasswordFailure(error));
return {
Expand All @@ -250,6 +251,6 @@ export const updateAccountPassword = (payload: {

dispatch(updateAccountPasswordSuccess(payload));

return { status: 'updateed', success: true };
return { status: 'updated', success: true };
};
};
48 changes: 48 additions & 0 deletions app/main_window/actions/domains/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,51 @@ export const updateMailbox = payload => {
return result;
};
};

/*
* Resend invitation to a claimable mailbox.
*/
export const RESEND_MAILBOX_INVITE_REQUEST =
'DOMAIN::RESEND_MAILBOX_INVITE_REQUEST';
export const resendMailboxInviteRequest = () => {
return {
type: RESEND_MAILBOX_INVITE_REQUEST
};
};

export const RESEND_MAILBOX_INVITE_SUCCESS =
'DOMAIN::RESEND_MAILBOX_INVITE_SUCCESS';
export const resendMailboxInviteSuccess = () => {
return {
type: RESEND_MAILBOX_INVITE_SUCCESS
};
};

export const RESEND_MAILBOX_INVITE_FAILURE =
'DOMAIN::RESEND_MAILBOX_INVITE_FAILURE';
export const resendMailboxInviteFailure = (error: Error) => {
return {
type: RESEND_MAILBOX_INVITE_FAILURE,
error
};
};

export const resendMailboxInvite = (payload: {
addr: string;
password: string;
inviteEmail: string;
}) => {
return async (dispatch: Dispatch) => {
dispatch(resendMailboxInviteRequest());
try {
await DomainService.resendMailboxInvitation(payload);
} catch (error) {
dispatch(resendMailboxInviteFailure(error));
return { status: error.message, success: false };
}

dispatch(resendMailboxInviteSuccess());

return { status: 'invitation-sent', success: true };
};
};
Loading

0 comments on commit 8fd1d71

Please sign in to comment.