Skip to content
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

[NEW] Alert admins when user requires approval & alert users when the account is approved/activated/deactivated #7098

Merged
merged 57 commits into from
Feb 20, 2018

Conversation

luisfn
Copy link
Contributor

@luisfn luisfn commented May 26, 2017

@RocketChat/core

Closes #976, #5977

The idea is to send a simple email to all admin users when an user register and needs approval to join. To acomplish this, a new field has been added where the user can fill a reason why he wants to join. The reason can be seen on user info screen and it is removed from user data after receive it's approval

image

image

image

image

@luisfn luisfn changed the title Issue 976 [FIX] Send email to admin when user requires approval May 26, 2017
@luisfn luisfn changed the title [FIX] Send email to admin when user requires approval WIP - [FIX] Send email to admin when user requires approval May 26, 2017
@CLAassistant
Copy link

CLAassistant commented May 26, 2017

CLA assistant check
All committers have signed the CLA.

luisfn added 18 commits May 27, 2017 00:37
- Added method to save reason into user object
- Added validation to display field but setting Accounts_ManuallyApproveNewUsers is not working :(
- Modified function placeholders to replace reason as well
- Modified email template on accounts.js
- Reason displayed only if setting is active and user is not active
- Added reason to getFullUserData
- Added method to save reason into user object
- Added validation to display field but setting Accounts_ManuallyApproveNewUsers is not working :(
- Modified function placeholders to replace reason as well
- Modified email template on accounts.js
- Reason displayed only if setting is active and user is not active
- Added reason to getFullUserData
Meteor.users.update(userId, { $unset: { 'reason' : 1 } });
return true;
}
});
Copy link
Member

Choose a reason for hiding this comment

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

This method shouldn't exist. First, it is not checking for user permission to unset reason, and second you could unset reason in the same method setUserActiveStatus.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@@ -9,6 +9,7 @@ class ModelUsers extends RocketChat.models._Base {
this.tryEnsureIndex({ 'active': 1 }, { sparse: 1 });
this.tryEnsureIndex({ 'statusConnection': 1 }, { sparse: 1 });
this.tryEnsureIndex({ 'type': 1 });
this.tryEnsureIndex({ 'reason': 1 });
Copy link
Member

Choose a reason for hiding this comment

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

Do you really need this index? I don't think we'll be doing any query/sorting using reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, just forgot it there. Removing

@@ -91,6 +118,27 @@ Accounts.onCreateUser(function(options, user = {}) {
}
}

if (!user.active) {
user.emails.some((email) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why are you using .some((email) => { if you are not using the email variable and you are also not returning a true value to stop the some? what's the expected result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No idea, was just folowing an example from another file sending email. Fixing

const destinations = [];

RocketChat.models.Roles.findUsersInRole('admin').forEach(function(adminUser) {
destinations.push(`${ adminUser.name }<${ adminUser.emails[0].address }>`);
Copy link
Member

Choose a reason for hiding this comment

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

It's possible that an adminUser doesn't have e-mail on adminUser.emails[0].address (for example if the admin only ever logged in using OAuth). You should check if property exists.


return false;
}
});
Copy link
Member

Choose a reason for hiding this comment

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

Likewise on client side, this method should not exist and its content should be executed inside setUserActiveStatus

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@MartinSchoeler MartinSchoeler dismissed their stale review June 2, 2017 15:02

Fixed the issues with the tests

@engelgabriel engelgabriel added this to the 0.62.0 milestone Jan 21, 2018
@rodrigok
Copy link
Member

Hi @luisfn could you fix the conflicts?

@graywolf336
Copy link
Contributor

@rodrigok This was opened in May of last year, we might as well fix the conflicts ourselves as that was a long time ago...

@rodrigok
Copy link
Member

@graywolf336 yes, lets fix the conflicts our selfs

# Conflicts:
#	packages/rocketchat-i18n/i18n/en.i18n.json
#	packages/rocketchat-lib/lib/placeholders.js
#	packages/rocketchat-lib/server/models/Users.js
#	packages/rocketchat-ui-flextab/client/tabs/userInfo.html
#	packages/rocketchat-ui-flextab/client/tabs/userInfo.js
@rodrigok rodrigok changed the title WIP - [FIX] Send email to admin when user requires approval [NEW] Alert admins when user requires approval & alert users when the account is activated or deactivated Feb 17, 2018
@rodrigok rodrigok changed the title [NEW] Alert admins when user requires approval & alert users when the account is activated or deactivated [NEW] Alert admins when user requires approval & alert users when the account is activated/deactivated Feb 17, 2018
@rodrigok rodrigok changed the title [NEW] Alert admins when user requires approval & alert users when the account is activated/deactivated [NEW] Alert admins when user requires approval & alert users when the account is approved/activated/deactivated Feb 17, 2018
@graywolf336
Copy link
Contributor

A few things, and this isn't related to this pull request directly, but whenever a user isn't activated and they try to login successfully (aka correct email and password) the error incorrectly says "invalid user or password" when the error returned via the websockets actually says error-user-is-not-activated. So, I think we need to display the screen again that states they are awaiting user registration.

Copy link
Contributor

@graywolf336 graywolf336 left a comment

Choose a reason for hiding this comment

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

Works fine when I tested locally. 👍

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.

7 participants