[NEW] Alert admins when user requires approval & alert users when the account is approved/activated/deactivated#7098
[NEW] Alert admins when user requires approval & alert users when the account is approved/activated/deactivated#7098rodrigok merged 57 commits intoRocketChat:developfrom luisfn:issue_976
Conversation
- 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
client/methods/unsetUserReason.js
Outdated
| Meteor.users.update(userId, { $unset: { 'reason' : 1 } }); | ||
| return true; | ||
| } | ||
| }); |
There was a problem hiding this comment.
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.
| this.tryEnsureIndex({ 'active': 1 }, { sparse: 1 }); | ||
| this.tryEnsureIndex({ 'statusConnection': 1 }, { sparse: 1 }); | ||
| this.tryEnsureIndex({ 'type': 1 }); | ||
| this.tryEnsureIndex({ 'reason': 1 }); |
There was a problem hiding this comment.
Do you really need this index? I don't think we'll be doing any query/sorting using reason.
There was a problem hiding this comment.
No, just forgot it there. Removing
server/lib/accounts.js
Outdated
| } | ||
|
|
||
| if (!user.active) { | ||
| user.emails.some((email) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
No idea, was just folowing an example from another file sending email. Fixing
server/lib/accounts.js
Outdated
| const destinations = []; | ||
|
|
||
| RocketChat.models.Roles.findUsersInRole('admin').forEach(function(adminUser) { | ||
| destinations.push(`${ adminUser.name }<${ adminUser.emails[0].address }>`); |
There was a problem hiding this comment.
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.
server/methods/unsetUserReason.js
Outdated
|
|
||
| return false; | ||
| } | ||
| }); |
There was a problem hiding this comment.
Likewise on client side, this method should not exist and its content should be executed inside setUserActiveStatus
# Conflicts: # server/lib/accounts.js
|
Hi @luisfn could you fix the conflicts? |
|
@rodrigok This was opened in May of last year, we might as well fix the conflicts ourselves as that was a long time ago... |
|
@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
|
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 |
graywolf336
left a comment
There was a problem hiding this comment.
Works fine when I tested locally. 👍
@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