Skip to content

Bugfix/ask email confirmation when adding organisation manager #3398

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

deligence-dharmendra
Copy link
Contributor

Closes #3346

Changes

  • changes in language, schema, organization router file
  • add new send email verification and verify email method in organization method

Developer checklist

This checklist is to be completed by the PR developer:

  • Alternative solutions were compared/discussed before writing code
    • trade-offs with this solution are considered acceptable
  • Code in this PR adheres to the project styleguide
  • This pull request does not decrease project test coverage
  • If the code changes existing database collection(s), migration has been written
  • If UI texts are added or changed, all texts are internationalized

Reviewer checklist

Reviewed by: @username1

This list is to be completed by the pull request reviewer:

  • Code works as described/expected
  • Code seems to be error free
    • no browser console errors visible
    • no server console errors visible
    • passes CI build
  • Code is written in a way that promotes maintainability
    • easy to understand
    • well organized
    • follows project coding standards and conventions
    • well documented

@Nazarah
Copy link
Contributor

Nazarah commented Feb 19, 2018

Fix the following:
"In case mail sending fails, the s-alert notifying the user about this remains in the page.
It doesn't automatically vanishes."

@Nazarah
Copy link
Contributor

Nazarah commented Feb 19, 2018

@deligence-dharmendra @matleppa I was trying to test the fix from my localhost.
I tried to setup the email configuration from the settings and tried to add another user as a manager.
On clicking Add Manager, it shows the message "Sending Verification Email failed" as S alert.
The user isn't added eventually as an organization manager.
My question is that do I need to set up valid email configuration information (i.e. same as that in nightly APInf) in order to verify the mail settings?

@deligence-dharmendra
Copy link
Contributor Author

@Nazarah Yes, you need to set up valid email configuration information. Otherwise, email id does not add to the organization and its show error message as an s-alert on the same page.

sending email verification error

@Nazarah
Copy link
Contributor

Nazarah commented Feb 20, 2018

@deligence-dharmendra @matleppa Just ran the feature in my localhost.
When user confirms the email by clicking on the link, he gets redirected to the home page of APInf.
Shouldn't it be the case that on clicking the verification link, user gets redirected to the Organization profile page?

@@ -22,6 +22,12 @@ AutoForm.hooks({

// Add current user as Organization manager & creater
organization.managerIds = [userId];
organization.emailVerification = [];
// Set default value for the owner of organization
organization.emailVerification.push({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

organization.emailVerification = [{....}];

?

{{/ if }}
<div class="pull-right">
{{# unless emailVerified }}
<span class="label label-default">Unverified</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. i18n tag for this word is missed
  2. Nested element should have a new line

// Get email verification status
const result = _.find(organization.emailVerification, { managerIds: user._id });
// In case of existing organizations
if (typeof result === 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make invert of this if-else & simplify

// Construct empty object
let verificationData = {};
const result = _.find(organization.emailVerification, { managerIds: user._id });
if (result) {
  varidicationData = result
} else {  
verificationData.verified = organization.createdBy === user._id;
}

If organization.emailVerification is undefined then result variable is undefined as well
Remake

@matleppa
Copy link
Member

@deligence-dharmendra I agree with @Nazarah about User getting redirected to Organization page while verificating.

Copy link
Member

@matleppa matleppa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some findings.

const response = Meteor.call('sendEmailVerification', user._id);

// Check error type
if (response.message === 'failed' && response.message === 'email-failed') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine checks.
Outer check
response.status === 'failed'
inner checks
response.message === 'email-failed'
response.message === 'mail-setting-invalid'

return resp;
} else {
// Throw Authentication error for client
throw new Meteor.Error(`Email verification failed. Authentication token doesn't exists in db.`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists --> exist

@marla-singer marla-singer force-pushed the bugfix/ask-email-confirmation-when-adding-organisation-manager branch from 2428080 to 08156d1 Compare February 22, 2018 10:02
@ghost ghost assigned marla-singer Feb 22, 2018
Copy link
Contributor

@marla-singer marla-singer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deligence-dharmendra Great job 👍 Work as expected
I made rebase to squash your commit

@marla-singer marla-singer force-pushed the bugfix/ask-email-confirmation-when-adding-organisation-manager branch from 08156d1 to a61f014 Compare February 22, 2018 10:11
@marla-singer marla-singer merged commit 3a9f1a3 into develop Feb 22, 2018
@ghost ghost removed the Ready for review label Feb 22, 2018
@marla-singer marla-singer deleted the bugfix/ask-email-confirmation-when-adding-organisation-manager branch February 22, 2018 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants