-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
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.
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
.
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.
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 }); |
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.
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.
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
server/lib/accounts.js
Outdated
@@ -91,6 +118,27 @@ Accounts.onCreateUser(function(options, user = {}) { | |||
} | |||
} | |||
|
|||
if (!user.active) { | |||
user.emails.some((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.
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.
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
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.
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.
server/methods/unsetUserReason.js
Outdated
|
||
return 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.
Likewise on client side, this method should not exist and its content should be executed inside setUserActiveStatus
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.
Removed
# 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 |
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.
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