parent
1ced54e6a8
commit
cfe5068fec
@ -0,0 +1,20 @@ |
||||
Meteor.methods({ |
||||
afterVerifyEmail() { |
||||
const userId = Meteor.userId(); |
||||
|
||||
if (!userId) { |
||||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { |
||||
method: 'afterVerifyEmail' |
||||
}); |
||||
} |
||||
|
||||
const user = RocketChat.models.Users.findOneById(userId); |
||||
|
||||
const verifiedEmail = _.find(user.emails, (email) => email.verified); |
||||
|
||||
if (verifiedEmail) { |
||||
RocketChat.models.Roles.addUserRoles(user._id, 'user'); |
||||
RocketChat.models.Roles.removeUserRoles(user._id, 'anonymous'); |
||||
} |
||||
} |
||||
}); |
@ -0,0 +1,12 @@ |
||||
RocketChat.Migrations.add({ |
||||
version: 93, |
||||
up() { |
||||
|
||||
if (RocketChat && RocketChat.models && RocketChat.models.Settings) { |
||||
const setting = RocketChat.models.Settings.findOne({ _id: 'Accounts_AllowAnonymousAccess' }); |
||||
if (setting && setting.value === true) { |
||||
RocketChat.models.Settings.update({ _id: 'Accounts_AllowAnonymousRead' }, { $set: { value: setting.value } }); |
||||
} |
||||
} |
||||
} |
||||
}); |
Loading…
Reference in new issue