Skip to content

Commit f307388

Browse files
authored
Merge pull request #1475 from javiteri95/newRecoveryEmailValidations
New recovery email validations
2 parents 7840715 + 3ab4450 commit f307388

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+951
-63
lines changed

electron_app/electron-starter.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ async function initApp() {
101101
composerWindowManager.sendEventToMailbox('failed-to-send', undefined);
102102
});
103103

104+
ipcMain.on('send-recovery-email', () => {
105+
composerWindowManager.sendEventToMailbox('send-recovery-email', undefined)
106+
})
107+
108+
ipcMain.on('open-recovery-email-mailbox', (ev,params) => {
109+
composerWindowManager.sendEventToMailbox('open-recovery-email-mailbox', params)
110+
})
111+
104112
// Socket
105113
socketClient.setMessageListener(async data => {
106114
const { cmd, recipientId, domain } = data;

electron_app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
"electron-notarize": "^0.1.1"
151151
},
152152
"dependencies": {
153-
"@criptext/api": "^0.15.35",
153+
"@criptext/api": "^0.15.37",
154154
"@criptext/data-transfer-client": "^0.1.1",
155155
"@criptext/electron-better-ipc": "^0.7.0-rc1-0.2",
156156
"@criptext/electron-push-receiver": "^2.1.3",

electron_app/src/clientManager.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ const canLogin = async ({ username, domain }) => {
200200
return await client.canLogin({ username, domain });
201201
};
202202

203+
const canSend = async params => {
204+
const { recipientId } = params;
205+
const client = await createClient({ recipientId });
206+
const res = await client.canSend();
207+
return res.status === 200
208+
? res
209+
: await checkExpiredSession(res, canSend, params);
210+
};
211+
203212
const changeRecoveryEmail = async params => {
204213
const { recipientId } = params;
205214
const client = await createClient({ recipientId });
@@ -754,6 +763,7 @@ module.exports = {
754763
activateAddress,
755764
acknowledgeEvents,
756765
canLogin,
766+
canSend,
757767
blockRemoteContent,
758768
changePassword,
759769
changeRecoveryEmail,

electron_app/src/globalManager.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ global.composerData = {};
66
global.emailToEdit = {};
77
global.isMAS = INSTALLER_TYPE === allInstallerTypes.mac.store;
88
global.loadingData = {};
9+
global.loginData = {};
910
global.pinData = {};
1011
global.temporalAccount = {};
1112
global.windowsEventsDisabled = false;
@@ -60,6 +61,15 @@ const getLoadingData = () => {
6061
return global.loadingData;
6162
};
6263

64+
/* Login
65+
----------------------------- */
66+
const setLoginData = data => {
67+
global.loginData = data;
68+
};
69+
const getLoginData = () => {
70+
return global.loginData;
71+
};
72+
6373
/* Pin
6474
----------------------------- */
6575
const setPinData = data => {
@@ -172,6 +182,10 @@ module.exports = {
172182
get: getLoadingData,
173183
set: setLoadingData
174184
},
185+
loginData: {
186+
get: getLoginData,
187+
set: setLoginData
188+
},
175189
pinData: {
176190
get: getPinData,
177191
set: setPinData

electron_app/src/ipc/client.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ ipc.answerRenderer('client-can-login', ({ username, domain }) =>
1515
clientManager.canLogin({ username, domain })
1616
);
1717

18+
ipc.answerRenderer('client-can-send', params => {
19+
const recipientId =
20+
params && params.recipientId ? params.recipientId : myAccount.recipientId;
21+
const data = { recipientId };
22+
return clientManager.canSend(data);
23+
});
24+
1825
ipc.answerRenderer('client-change-password', params => {
1926
const data = { ...params, recipientId: myAccount.recipientId };
2027
return clientManager.changePassword(data);
@@ -178,8 +185,10 @@ ipc.answerRenderer('client-report-phishing', params => {
178185
return clientManager.reportPhishing(data);
179186
});
180187

181-
ipc.answerRenderer('client-resend-confirmation-email', () => {
182-
return clientManager.resendConfirmationEmail(myAccount.recipientId);
188+
ipc.answerRenderer('client-resend-confirmation-email', params => {
189+
const recipientId =
190+
params && params.recipientId ? params.recipientId : myAccount.recipientId;
191+
return clientManager.resendConfirmationEmail(recipientId);
183192
});
184193

185194
ipc.answerRenderer('client-reset-password', params =>

electron_app/src/ipc/login.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { ipcMain: ipc } = require('@criptext/electron-better-ipc');
22
const loginWindow = require('../windows/login');
3+
const globalManager = require('../globalManager');
34
const { checkForUpdates } = require('./../updater');
45
const { openUpgradeToPlusWindow } = require('../windows/upgradePlus');
56

@@ -11,7 +12,8 @@ ipc.answerRenderer('minimize-login', () => {
1112
loginWindow.minimize();
1213
});
1314

14-
ipc.answerRenderer('open-login', () => {
15+
ipc.answerRenderer('open-login', params => {
16+
if (params) globalManager.loginData.set(params);
1517
loginWindow.show();
1618
});
1719

electron_app/src/ipc/mailbox.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ ipc.answerRenderer('maximize-mailbox', () => {
3838
mailboxWindow.toggleMaximize();
3939
});
4040

41+
ipc.answerRenderer('focus-mailbox', () => {
42+
mailboxWindow.focus();
43+
});
44+
4145
ipc.answerRenderer('minimize-mailbox', () => {
4246
mailboxWindow.minimize();
4347
});

electron_app/src/windows/mailbox.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ const show = async ({ firstOpenApp = false }) => {
129129
}
130130
};
131131

132+
const focus = () => {
133+
if (mailboxWindow && mailboxWindow.focus) {
134+
mailboxWindow.focus();
135+
}
136+
};
137+
132138
const hide = () => {
133139
if (mailboxWindow && mailboxWindow.hide) {
134140
mailboxWindow.hide();
@@ -200,6 +206,7 @@ function getWindow() {
200206
module.exports = {
201207
close,
202208
hide,
209+
focus,
203210
getShowPreview,
204211
getWindow,
205212
send,

electron_app/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@
115115
lodash "^4.2.0"
116116
to-fast-properties "^2.0.0"
117117

118-
"@criptext/api@^0.15.35":
119-
version "0.15.35"
120-
resolved "https://registry.yarnpkg.com/@criptext/api/-/api-0.15.35.tgz#634e40d1437fbf212681708e67690cf3d0e75e4e"
121-
integrity sha512-bxBYBv/wbghu8p/OcmtnvTkEdBgU7XsnkifR0yq4ZoTspAMfp4GN6KXE8t/8PTmwxH9xQpktc1B+44NlXER1KQ==
118+
"@criptext/api@^0.15.37":
119+
version "0.15.37"
120+
resolved "https://registry.yarnpkg.com/@criptext/api/-/api-0.15.37.tgz#9cfed4e381a80d57adb8bba56946a27490685449"
121+
integrity sha512-kHR8vBdKYd+NCUxkLUURiJIyl2dwAj1/XR4OnWHd6aIrm3ZUUBp9WXHrFRD879NOvQPHUSBt5bbn5qU/PKZdfw==
122122
dependencies:
123123
superagent "^3.8.2"
124124

email_composer/src/components/Composer.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ import BodyWrapper from './BodyWrapper';
77
import NonCriptextPopupWrapper from './NonCriptextPopupWrapper';
88
import { Status } from './Control';
99
import { mySettings } from '../utils/electronInterface';
10+
import PopupHOC from './PopupHOC';
11+
import NotVerifiedRecoveryEmailPopup from '../components/NotVerifiedRecoveryEmailPopup';
12+
import RecoveryEmailSentPopup from '../components/RecoveryEmailSentPopup';
1013
import './composer.scss';
1114

15+
const NotverifiedrecoveryemailPopup = PopupHOC(NotVerifiedRecoveryEmailPopup);
16+
const Recoveryemailsentpopup = PopupHOC(RecoveryEmailSentPopup);
17+
1218
const Composer = props => (
1319
<div className="wrapper" data-theme={mySettings.theme || 'light'}>
1420
<FromWrapper
@@ -64,6 +70,21 @@ const Composer = props => (
6470
}
6571
/>
6672
)}
73+
{props.displayNotVerifiedRecoveryEmailPopup && (
74+
<NotverifiedrecoveryemailPopup
75+
popupPosition={{ left: '45%', top: '45%' }}
76+
onConfirmVerifyRecoveryEmail={props.handleConfirmVerifyRecoveryEmail}
77+
onTogglePopup={props.onTogglePopupNotVerifiedRecoveryEmail}
78+
theme={'dark'}
79+
/>
80+
)}
81+
{props.displayRecoveryEmailSentPopup && (
82+
<Recoveryemailsentpopup
83+
popupPosition={{ left: '45%', top: '45%' }}
84+
onTogglePopup={props.onToggleRecoveryEmailSentPopup}
85+
theme={'dark'}
86+
/>
87+
)}
6788
{(props.status === Status.WAITING ||
6889
props.status === Status.INITIALIZING ||
6990
props.isLinkingDevices) && <div className="composer-disable" />}
@@ -79,13 +100,16 @@ Composer.propTypes = {
79100
ccEmails: PropTypes.array,
80101
disableSendButtonOnInvalidEmail: PropTypes.func,
81102
displayNonCriptextPopup: PropTypes.bool,
103+
displayNotVerifiedRecoveryEmailPopup: PropTypes.bool,
104+
displayRecoveryEmailSentPopup: PropTypes.bool,
82105
files: PropTypes.array,
83106
getAccount: PropTypes.func,
84107
getBccEmails: PropTypes.func,
85108
getCcEmails: PropTypes.func,
86109
getHtmlBody: PropTypes.func,
87110
getTextSubject: PropTypes.func,
88111
getToEmails: PropTypes.func,
112+
handleConfirmVerifyRecoveryEmail: PropTypes.func,
89113
handlePauseUploadFile: PropTypes.func,
90114
handleResumeUploadFile: PropTypes.func,
91115
htmlBody: PropTypes.string,
@@ -103,7 +127,9 @@ Composer.propTypes = {
103127
onClickSendMessage: PropTypes.func,
104128
onDragOver: PropTypes.func,
105129
onSetNonCriptextRecipientsPassword: PropTypes.func,
130+
onTogglePopupNotVerifiedRecoveryEmail: PropTypes.func,
106131
onToggleRecipient: PropTypes.func,
132+
onToggleRecoveryEmailSentPopup: PropTypes.func,
107133
status: PropTypes.number,
108134
tagBlured: PropTypes.func,
109135
tagChanged: PropTypes.func,

0 commit comments

Comments
 (0)