From 5a94625486ec51b7560dbd0379294960ff7091a2 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Sat, 7 Sep 2024 18:29:34 +0300 Subject: [PATCH 01/14] Implement validateUsername method --- src/components/Auth/SignUp/SignUp.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/Auth/SignUp/SignUp.js b/src/components/Auth/SignUp/SignUp.js index 12ab716b3..cd4b1e475 100644 --- a/src/components/Auth/SignUp/SignUp.js +++ b/src/components/Auth/SignUp/SignUp.js @@ -8,6 +8,8 @@ import { Dialog, Intent, } from '@blueprintjs/core' +import _map from 'lodash/map' +import _includes from 'lodash/includes' import Icon from 'icons' import config from 'config' @@ -85,6 +87,8 @@ class SignUp extends PureComponent { }) tracker.trackEvent('Add Account') const isValid = this.validateForm() + const isRegisteredUserName = this.validateUsername(userName) + console.log('+++isRegisteredUserName', isRegisteredUserName) if (isValid) { if (useApiKey) { signUp({ @@ -144,6 +148,14 @@ class SignUp extends PureComponent { return isValid } + validateUsername = (userName) => { + const { users } = this.props + const isRegisteredUserName = _includes( + _map(users, user => user.email), userName, + ) + return isRegisteredUserName + } + handleInputChange = (e) => { const { isBeingValidated } = this.state const { name, value } = e.target From 1baed4cf520392f8e8ec8b9715dd90dadba79ba3 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Sat, 7 Sep 2024 18:46:19 +0300 Subject: [PATCH 02/14] Add registered user picking helper --- src/components/Auth/SignUp/SignUp.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Auth/SignUp/SignUp.js b/src/components/Auth/SignUp/SignUp.js index cd4b1e475..60ec0452b 100644 --- a/src/components/Auth/SignUp/SignUp.js +++ b/src/components/Auth/SignUp/SignUp.js @@ -9,6 +9,8 @@ import { Intent, } from '@blueprintjs/core' import _map from 'lodash/map' +import _find from 'lodash/find' +import _isEqual from 'lodash/isEqual' import _includes from 'lodash/includes' import Icon from 'icons' @@ -71,7 +73,7 @@ class SignUp extends PureComponent { } onSignUp = () => { - const { signUp, signUpEmail } = this.props + const { signUp, signUpEmail, users } = this.props const { apiKey, apiSecret, @@ -88,7 +90,6 @@ class SignUp extends PureComponent { tracker.trackEvent('Add Account') const isValid = this.validateForm() const isRegisteredUserName = this.validateUsername(userName) - console.log('+++isRegisteredUserName', isRegisteredUserName) if (isValid) { if (useApiKey) { signUp({ @@ -98,6 +99,11 @@ class SignUp extends PureComponent { isNotProtected: !isPasswordProtected, isPersisted, }) + } else if (isRegisteredUserName) { + const registeredUser = _find(users, user => _isEqual(user.email, userName)) + console.log('+++isRegisteredUserName', isRegisteredUserName) + console.log('++userName', userName) + console.log('++registeredUser', registeredUser) } else { signUpEmail({ login: userName, From 5e00326f8f96a4ee1aaa090be414d7c6fc7fed80 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Sat, 7 Sep 2024 19:14:48 +0300 Subject: [PATCH 03/14] Add accAddedWithApiKey description --- public/locales/en/translations.json | 1 + 1 file changed, 1 insertion(+) diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index d7edfbfaa..32de4a991 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -67,6 +67,7 @@ "apiSecret": "API Secret", "accWithApiKey": "Add account with API key", "accWithoutApiKey": "Add account without API key", + "accAddedWithApiKey": "You have already added this account using an API key", "simpleAccounts": "Simple Accounts", "multipleAccounts": "Multiple Accounts", "login": "Login", From 055cdac38002edcf1110d0723aac18125c47dbd5 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Sat, 7 Sep 2024 19:15:13 +0300 Subject: [PATCH 04/14] Update sign up container --- src/components/Auth/SignUp/SignUp.container.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/Auth/SignUp/SignUp.container.js b/src/components/Auth/SignUp/SignUp.container.js index c12e071e4..dfa7645e6 100644 --- a/src/components/Auth/SignUp/SignUp.container.js +++ b/src/components/Auth/SignUp/SignUp.container.js @@ -9,6 +9,7 @@ import { signUpEmail, showOtpLogin, } from 'state/auth/actions' +import { updateStatus } from 'state/status/actions' import { getUsers, getAuthData, @@ -31,6 +32,7 @@ const mapDispatchToProps = { updateAuth, signUpEmail, showOtpLogin, + updateStatus, } export default compose( From fcc138a73bb13a0e838c8b336e02a95f436a78ba Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Sat, 7 Sep 2024 19:16:02 +0300 Subject: [PATCH 05/14] Implement existing account notification --- src/components/Auth/SignUp/SignUp.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Auth/SignUp/SignUp.js b/src/components/Auth/SignUp/SignUp.js index 60ec0452b..ef6cc5ea3 100644 --- a/src/components/Auth/SignUp/SignUp.js +++ b/src/components/Auth/SignUp/SignUp.js @@ -18,7 +18,7 @@ import config from 'config' import { tracker } from 'utils/trackers' import PlatformLogo from 'ui/PlatformLogo' -import { MODES } from '../Auth' +import { AUTH_TYPES, MODES } from '../Auth' import LoginOtp from '../LoginOtp' import LoginEmail from '../LoginEmail' import LoginApiKey from '../LoginApiKey' @@ -73,7 +73,9 @@ class SignUp extends PureComponent { } onSignUp = () => { - const { signUp, signUpEmail, users } = this.props + const { + signUp, signUpEmail, users, switchMode, updateStatus, + } = this.props const { apiKey, apiSecret, @@ -101,6 +103,10 @@ class SignUp extends PureComponent { }) } else if (isRegisteredUserName) { const registeredUser = _find(users, user => _isEqual(user.email, userName)) + updateStatus({ id: 'auth.accAddedWithApiKey' }) + switchMode(MODES.SIGN_IN) + + console.log('+++isRegisteredUserName', isRegisteredUserName) console.log('++userName', userName) console.log('++registeredUser', registeredUser) From 155bb73bfc81dd810190da0a15ceb564749323a2 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Sat, 7 Sep 2024 19:19:52 +0300 Subject: [PATCH 06/14] Actualize sign up prop-types and cleanup --- src/components/Auth/SignUp/SignUp.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/Auth/SignUp/SignUp.js b/src/components/Auth/SignUp/SignUp.js index ef6cc5ea3..34c2cb867 100644 --- a/src/components/Auth/SignUp/SignUp.js +++ b/src/components/Auth/SignUp/SignUp.js @@ -9,8 +9,8 @@ import { Intent, } from '@blueprintjs/core' import _map from 'lodash/map' -import _find from 'lodash/find' -import _isEqual from 'lodash/isEqual' +// import _find from 'lodash/find' +// import _isEqual from 'lodash/isEqual' import _includes from 'lodash/includes' import Icon from 'icons' @@ -44,6 +44,7 @@ class SignUp extends PureComponent { showOtpLogin: PropTypes.func.isRequired, isOtpLoginShown: PropTypes.bool.isRequired, switchMode: PropTypes.func.isRequired, + updateStatus: PropTypes.func.isRequired, users: PropTypes.arrayOf(PropTypes.shape({ email: PropTypes.string.isRequired, isSubAccount: PropTypes.bool.isRequired, @@ -74,7 +75,11 @@ class SignUp extends PureComponent { onSignUp = () => { const { - signUp, signUpEmail, users, switchMode, updateStatus, + // users, + signUp, + switchMode, + signUpEmail, + updateStatus, } = this.props const { apiKey, @@ -102,14 +107,9 @@ class SignUp extends PureComponent { isPersisted, }) } else if (isRegisteredUserName) { - const registeredUser = _find(users, user => _isEqual(user.email, userName)) + // const registeredUser = _find(users, user => _isEqual(user.email, userName)) updateStatus({ id: 'auth.accAddedWithApiKey' }) switchMode(MODES.SIGN_IN) - - - console.log('+++isRegisteredUserName', isRegisteredUserName) - console.log('++userName', userName) - console.log('++registeredUser', registeredUser) } else { signUpEmail({ login: userName, From e3495c4db01dd7830b65c7e7f36bdb840a545eb2 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 9 Sep 2024 11:49:52 +0300 Subject: [PATCH 07/14] Cleanup --- src/components/Auth/SignUp/SignUp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Auth/SignUp/SignUp.js b/src/components/Auth/SignUp/SignUp.js index 34c2cb867..cedc75dc6 100644 --- a/src/components/Auth/SignUp/SignUp.js +++ b/src/components/Auth/SignUp/SignUp.js @@ -18,7 +18,7 @@ import config from 'config' import { tracker } from 'utils/trackers' import PlatformLogo from 'ui/PlatformLogo' -import { AUTH_TYPES, MODES } from '../Auth' +import { MODES } from '../Auth' import LoginOtp from '../LoginOtp' import LoginEmail from '../LoginEmail' import LoginApiKey from '../LoginApiKey' From fd8a871cd90061d4f14f2c4aa9d3fdb6bfb1ba70 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 9 Sep 2024 12:37:35 +0300 Subject: [PATCH 08/14] Implement handleExistingUser dedicated helper --- src/components/Auth/SignUp/SignUp.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/components/Auth/SignUp/SignUp.js b/src/components/Auth/SignUp/SignUp.js index cedc75dc6..d546ade41 100644 --- a/src/components/Auth/SignUp/SignUp.js +++ b/src/components/Auth/SignUp/SignUp.js @@ -9,8 +9,8 @@ import { Intent, } from '@blueprintjs/core' import _map from 'lodash/map' -// import _find from 'lodash/find' -// import _isEqual from 'lodash/isEqual' +import _find from 'lodash/find' +import _isEqual from 'lodash/isEqual' import _includes from 'lodash/includes' import Icon from 'icons' @@ -74,13 +74,7 @@ class SignUp extends PureComponent { } onSignUp = () => { - const { - // users, - signUp, - switchMode, - signUpEmail, - updateStatus, - } = this.props + const { signUp, signUpEmail } = this.props const { apiKey, apiSecret, @@ -107,9 +101,7 @@ class SignUp extends PureComponent { isPersisted, }) } else if (isRegisteredUserName) { - // const registeredUser = _find(users, user => _isEqual(user.email, userName)) - updateStatus({ id: 'auth.accAddedWithApiKey' }) - switchMode(MODES.SIGN_IN) + this.handleExistingUser(userName) } else { signUpEmail({ login: userName, @@ -168,6 +160,13 @@ class SignUp extends PureComponent { return isRegisteredUserName } + handleExistingUser = (userName) => { + const { users, switchMode, updateStatus } = this.props + const registeredUser = _find(users, user => _isEqual(user.email, userName)) + updateStatus({ id: 'auth.accAddedWithApiKey' }) + switchMode(MODES.SIGN_IN) + } + handleInputChange = (e) => { const { isBeingValidated } = this.state const { name, value } = e.target From 8640fae345385255ebfbb2f8590d7d051e1bea30 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 9 Sep 2024 12:47:57 +0300 Subject: [PATCH 09/14] Implement auto sign-in for unprotected existing accs --- src/components/Auth/SignUp/SignUp.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/Auth/SignUp/SignUp.js b/src/components/Auth/SignUp/SignUp.js index d546ade41..18e30fa25 100644 --- a/src/components/Auth/SignUp/SignUp.js +++ b/src/components/Auth/SignUp/SignUp.js @@ -161,10 +161,17 @@ class SignUp extends PureComponent { } handleExistingUser = (userName) => { - const { users, switchMode, updateStatus } = this.props + const { + users, switchMode, updateStatus, signIn, + } = this.props const registeredUser = _find(users, user => _isEqual(user.email, userName)) + const { email, isNotProtected } = registeredUser updateStatus({ id: 'auth.accAddedWithApiKey' }) - switchMode(MODES.SIGN_IN) + if (isNotProtected) { + signIn({ email }) + } else { + switchMode(MODES.SIGN_IN) + } } handleInputChange = (e) => { From 060859290977d981d8692d3c979f77b21fce6921 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 9 Sep 2024 12:48:24 +0300 Subject: [PATCH 10/14] Update sing-up mapped methods --- src/components/Auth/SignUp/SignUp.container.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/Auth/SignUp/SignUp.container.js b/src/components/Auth/SignUp/SignUp.container.js index dfa7645e6..0257be424 100644 --- a/src/components/Auth/SignUp/SignUp.container.js +++ b/src/components/Auth/SignUp/SignUp.container.js @@ -3,6 +3,7 @@ import { connect } from 'react-redux' import { withTranslation } from 'react-i18next' import { + signIn, signUp, signUpOtp, updateAuth, @@ -27,6 +28,7 @@ const mapStateToProps = state => ({ }) const mapDispatchToProps = { + signIn, signUp, signUpOtp, updateAuth, From b5bcd1a7796a4df115346cab7eb380967f34b1b0 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 9 Sep 2024 12:50:35 +0300 Subject: [PATCH 11/14] Actualize sign-up prop-types --- src/components/Auth/SignUp/SignUp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Auth/SignUp/SignUp.js b/src/components/Auth/SignUp/SignUp.js index 18e30fa25..a1b3416a0 100644 --- a/src/components/Auth/SignUp/SignUp.js +++ b/src/components/Auth/SignUp/SignUp.js @@ -38,6 +38,7 @@ class SignUp extends PureComponent { }).isRequired, loading: PropTypes.bool.isRequired, t: PropTypes.func.isRequired, + signIn: PropTypes.func.isRequired, signUp: PropTypes.func.isRequired, signUpOtp: PropTypes.func.isRequired, signUpEmail: PropTypes.func.isRequired, From 0dc1a0b67729264e02e911b13665b9f4b49800db Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 9 Sep 2024 12:52:29 +0300 Subject: [PATCH 12/14] Add existing acc auto login key/description --- public/locales/en/translations.json | 1 + 1 file changed, 1 insertion(+) diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index 32de4a991..37e365b7c 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -68,6 +68,7 @@ "accWithApiKey": "Add account with API key", "accWithoutApiKey": "Add account without API key", "accAddedWithApiKey": "You have already added this account using an API key", + "accAddedWithApiKeyLogin": "You have already added this account using an API key, logging you in...", "simpleAccounts": "Simple Accounts", "multipleAccounts": "Multiple Accounts", "login": "Login", From 06b03de5155899103bff7270f184f227e319a2d8 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 9 Sep 2024 13:10:02 +0300 Subject: [PATCH 13/14] Adjust toasts styling --- src/components/Auth/SignUp/SignUp.js | 3 ++- src/components/Status/_Status.scss | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Auth/SignUp/SignUp.js b/src/components/Auth/SignUp/SignUp.js index a1b3416a0..e8c49b569 100644 --- a/src/components/Auth/SignUp/SignUp.js +++ b/src/components/Auth/SignUp/SignUp.js @@ -167,11 +167,12 @@ class SignUp extends PureComponent { } = this.props const registeredUser = _find(users, user => _isEqual(user.email, userName)) const { email, isNotProtected } = registeredUser - updateStatus({ id: 'auth.accAddedWithApiKey' }) if (isNotProtected) { + updateStatus({ id: 'auth.accAddedWithApiKeyLogin' }) signIn({ email }) } else { switchMode(MODES.SIGN_IN) + updateStatus({ id: 'auth.accAddedWithApiKey' }) } } diff --git a/src/components/Status/_Status.scss b/src/components/Status/_Status.scss index c582de533..294037fa1 100644 --- a/src/components/Status/_Status.scss +++ b/src/components/Status/_Status.scss @@ -4,6 +4,7 @@ .bp3-toast { min-height: 40px; + max-width: 550px; padding: 5px; border-radius: 2px; align-items: center; From eff0f60270755cb992356f3709d15442e4b1a53e Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 11 Sep 2024 13:25:12 +0300 Subject: [PATCH 14/14] Improve auto login hnadling flow --- src/components/Auth/SignUp/SignUp.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Auth/SignUp/SignUp.js b/src/components/Auth/SignUp/SignUp.js index e8c49b569..bb9058e48 100644 --- a/src/components/Auth/SignUp/SignUp.js +++ b/src/components/Auth/SignUp/SignUp.js @@ -166,10 +166,10 @@ class SignUp extends PureComponent { users, switchMode, updateStatus, signIn, } = this.props const registeredUser = _find(users, user => _isEqual(user.email, userName)) - const { email, isNotProtected } = registeredUser + const { email, isSubAccount, isNotProtected } = registeredUser if (isNotProtected) { updateStatus({ id: 'auth.accAddedWithApiKeyLogin' }) - signIn({ email }) + signIn({ email, isSubAccount }) } else { switchMode(MODES.SIGN_IN) updateStatus({ id: 'auth.accAddedWithApiKey' })