-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Moving accounts package into /imports, adding email update to profile #2745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/imports| sendUpdatedVerificationEmail(user._id); | ||
|
|
||
| // Sync users and accounts collections | ||
| syncUsersAndAccounts(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the best way to sync users and accounts... any input would be appreciated
| * @param {String} email - user email | ||
| * @returns {Boolean} - returns boolean | ||
| */ | ||
| export function updateEmailAddress(email) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a bit of research, this seems to be the way people update email addresses on Meteor, first by adding a new one, then removing the old one. There is no callback on meteor's Accounts.addEmail, so I think you kind of have to send it back tot he client and do it this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems sensible to me.
|
bitHound - Dependencies — 1 failing dependency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've already fixed everything, so I really only added all of these comments for reference. I'm pushing up my changes now. Give them a look/test. If everything works for you, I'm good to go on my end.
|
|
||
| this.state = { | ||
| email: props.email, | ||
| newEmail: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.state.newEmail isn't used anywhere.
| }; | ||
|
|
||
| this.handleFieldChange = this.handleFieldChange.bind(this); | ||
| this.handleSubmit = this.handleSubmit.bind(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These bindings aren't needed because you defined those as arrow functions (accomplishes the same thing).
|
|
||
| componentWillReceiveProps() { | ||
| this.setState({ showSpinner: false }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? I don't see how it does anything.
| const { email } = this.state; | ||
|
|
||
| Meteor.call("accounts/validation/email", email, false, (result, error) => { | ||
| if (error.error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All server communication or data fetching should always be in a container. This should just be passed in as an event handler prop. The UI component shouldn't need to know/care about how something gets done. It just handles the state of the UI.
|
|
||
| Meteor.call("accounts/updateEmailAddress", email, (err) => { | ||
| if (err) { | ||
| Alerts.toast(i18next.t("accountsUI.error.emailAlreadyExists", { err: error.message }), "error"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong error object here in the Alert. Should be err because error is from the upper scope.
| import { Reaction } from "/client/api"; | ||
| import { i18next } from "/client/api"; | ||
| import * as Collections from "/lib/collections"; | ||
| import UpdateEmail from "/imports/plugins/core/accounts/client/components/email/updateEmail"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a registered component so it can be overridden.
| */ | ||
| Template.accountProfile.helpers({ | ||
|
|
||
| UpdateEmail() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In both of these, the data fetching logic should be in a container, not the Blaze template.
| import classnames from "classnames/dedupe"; | ||
| import { registerComponent } from "@reactioncommerce/reaction-components"; | ||
|
|
||
| class ReactionAvatar extends Component { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any component that only has a render function should be a simple stateless function. None of the React lifecycle methods or state handling are being used, so a Component class adds unnecessary overhead.
This also depends on an email being passed in, so it should have a container wrapping it (currently being done by a Blaze template)
server/api/core/accounts/password.js
Outdated
| } | ||
|
|
||
| // make sure we have a valid address | ||
| if (!address || !_.includes(_.map(user.emails || [], "address"), address)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_.includes should be Array.includes (I know you likely copied this from the other email verification function that I wrote. Just trying to be do it right moving forward. :))
| * @param {String} email - user email | ||
| * @returns {Boolean} - returns boolean | ||
| */ | ||
| export function updateEmailAddress(email) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems sensible to me.
…e/reaction into ek-accountsPatch
|
@aaronjudd The |
…e/reaction into ek-accountsPatch
|
Would love to get this merged quickly please so we're able to pull the changes into a client project. |
Resolves issue #2740
Resolves issue #2493
Resolves issue #2778
Move some account related components from Move accounts package from
/client/modules/accountsinto/imports/plugins/core/accounts. Follow up task in #2746 .Add email update fields to profile page
Pull up
ReactionAvatarcomponent from client project into the coreFollow-up tasks:
Email copy for new email: #2778