Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
494cc031
Unverified
Commit
494cc031
authored
4 years ago
by
Rodrigo Nascimento
Committed by
Diego Sampaio
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] Email configs not updating after setting changes (#17578)
parent
8bc295e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/lib/accounts.js
+34
-12
34 additions, 12 deletions
server/lib/accounts.js
server/methods/sendConfirmationEmail.js
+2
-25
2 additions, 25 deletions
server/methods/sendConfirmationEmail.js
server/methods/sendForgotPasswordEmail.js
+2
-35
2 additions, 35 deletions
server/methods/sendForgotPasswordEmail.js
with
38 additions
and
72 deletions
server/lib/accounts.js
+
34
−
12
View file @
494cc031
...
...
@@ -13,16 +13,21 @@ import { Users as UsersRaw } from '../../app/models/server/raw';
import
{
addUserRoles
}
from
'
../../app/authorization
'
;
import
{
getAvatarSuggestionForUser
}
from
'
../../app/lib/server/functions
'
;
const
a
ccounts
C
onfig
=
{
A
ccounts
.
c
onfig
(
{
forbidClientAccountCreation
:
true
,
loginExpirationInDays
:
settings
.
get
(
'
Accounts_LoginExpiration
'
),
};
});
Accounts
.
config
(
accountsConfig
);
const
updateMailConfig
=
_
.
debounce
(()
=>
{
Accounts
.
_options
.
loginExpirationInDays
=
settings
.
get
(
'
Accounts_LoginExpiration
'
);
Accounts
.
emailTemplates
.
siteName
=
settings
.
get
(
'
Site_Name
'
);
Accounts
.
emailTemplates
.
siteName
=
settings
.
get
(
'
Site_Name
'
);
Accounts
.
emailTemplates
.
from
=
`
${
settings
.
get
(
'
Site_Name
'
)
}
<
${
settings
.
get
(
'
From_Email
'
)
}
>`
;
Accounts
.
emailTemplates
.
from
=
`
${
settings
.
get
(
'
Site_Name
'
)
}
<
${
settings
.
get
(
'
From_Email
'
)
}
>`
;
},
1000
);
Meteor
.
startup
(()
=>
{
settings
.
get
(
/^
(
Accounts_LoginExpiration|Site_Name|From_Email
)
$/
,
updateMailConfig
);
});
Accounts
.
emailTemplates
.
userToActivate
=
{
subject
()
{
...
...
@@ -63,10 +68,9 @@ Accounts.emailTemplates.userActivated = {
},
};
// const verifyEmailHtml = Accounts.emailTemplates.verifyEmail.html;
let
verifyEmailTemplate
=
''
;
let
enrollAccountTemplate
=
''
;
let
resetPasswordTemplate
=
''
;
Meteor
.
startup
(()
=>
{
Mailer
.
getTemplateWrapped
(
'
Verification_Email
'
,
(
value
)
=>
{
verifyEmailTemplate
=
value
;
...
...
@@ -74,17 +78,35 @@ Meteor.startup(() => {
Mailer
.
getTemplateWrapped
(
'
Accounts_Enrollment_Email
'
,
(
value
)
=>
{
enrollAccountTemplate
=
value
;
});
Mailer
.
getTemplateWrapped
(
'
Forgot_Password_Email
'
,
(
value
)
=>
{
resetPasswordTemplate
=
value
;
});
});
Accounts
.
emailTemplates
.
verifyEmail
.
html
=
function
(
user
,
url
)
{
url
=
url
.
replace
(
Meteor
.
absoluteUrl
(),
`
${
Meteor
.
absoluteUrl
()
}
login/`
);
return
Mailer
.
replace
(
verifyEmailTemplate
,
{
Verification_Url
:
url
});
Accounts
.
emailTemplates
.
verifyEmail
.
html
=
function
(
userModel
,
url
)
{
return
Mailer
.
replace
(
verifyEmailTemplate
,
{
Verification_Url
:
url
,
name
:
userModel
.
name
});
};
Accounts
.
emailTemplates
.
verifyEmail
.
subject
=
function
()
{
const
subject
=
settings
.
get
(
'
Verification_Email_Subject
'
);
return
Mailer
.
replace
(
subject
||
''
);
};
Accounts
.
urls
.
resetPassword
=
function
(
token
)
{
return
Meteor
.
absoluteUrl
(
`reset-password/
${
token
}
`
);
};
Accounts
.
emailTemplates
.
resetPassword
.
html
=
Accounts
.
emailTemplates
.
resetPassword
.
text
;
Accounts
.
emailTemplates
.
resetPassword
.
subject
=
function
(
userModel
)
{
return
Mailer
.
replace
(
settings
.
get
(
'
Forgot_Password_Email_Subject
'
)
||
''
,
{
name
:
userModel
.
name
,
});
};
Accounts
.
emailTemplates
.
resetPassword
.
html
=
function
(
userModel
,
url
)
{
return
Mailer
.
replacekey
(
Mailer
.
replace
(
resetPasswordTemplate
,
{
name
:
userModel
.
name
,
}),
'
Forgot_Password_Url
'
,
url
);
};
Accounts
.
emailTemplates
.
enrollAccount
.
subject
=
function
(
user
)
{
const
subject
=
settings
.
get
(
'
Accounts_Enrollment_Email_Subject
'
);
...
...
This diff is collapsed.
Click to expand it.
server/methods/sendConfirmationEmail.js
+
2
−
25
View file @
494cc031
...
...
@@ -2,44 +2,21 @@ import { Meteor } from 'meteor/meteor';
import
{
check
}
from
'
meteor/check
'
;
import
{
Accounts
}
from
'
meteor/accounts-base
'
;
import
*
as
Mailer
from
'
../../app/mailer
'
;
import
{
Users
}
from
'
../../app/models
'
;
import
{
settings
}
from
'
../../app/settings
'
;
let
subject
=
''
;
let
html
=
''
;
Meteor
.
startup
(()
=>
{
settings
.
get
(
'
Verification_Email_Subject
'
,
function
(
key
,
value
)
{
subject
=
Mailer
.
replace
(
value
||
''
);
});
Mailer
.
getTemplateWrapped
(
'
Verification_Email
'
,
function
(
value
)
{
html
=
value
;
});
});
Meteor
.
methods
({
sendConfirmationEmail
(
to
)
{
check
(
to
,
String
);
const
email
=
to
.
trim
();
const
user
=
Users
.
findOneByEmailAddress
(
email
);
const
user
=
Users
.
findOneByEmailAddress
(
email
,
{
fields
:
{
_id
:
1
}
}
);
if
(
!
user
)
{
return
false
;
}
Accounts
.
emailTemplates
.
verifyEmail
.
subject
=
function
(
/* userModel*/
)
{
return
subject
;
};
Accounts
.
emailTemplates
.
verifyEmail
.
html
=
function
(
userModel
,
url
)
{
return
Mailer
.
replace
(
html
,
{
Verification_Url
:
url
,
name
:
user
.
name
});
};
try
{
return
Accounts
.
sendVerificationEmail
(
user
.
_id
,
email
);
return
!!
Accounts
.
sendVerificationEmail
(
user
.
_id
,
email
);
}
catch
(
error
)
{
throw
new
Meteor
.
Error
(
'
error-email-send-failed
'
,
`Error trying to send email:
${
error
.
message
}
`
,
{
method
:
'
registerUser
'
,
...
...
This diff is collapsed.
Click to expand it.
server/methods/sendForgotPasswordEmail.js
+
2
−
35
View file @
494cc031
import
{
Meteor
}
from
'
meteor/meteor
'
;
import
{
check
}
from
'
meteor/check
'
;
import
{
Accounts
}
from
'
meteor/accounts-base
'
;
import
s
from
'
underscore.string
'
;
import
*
as
Mailer
from
'
../../app/mailer
'
;
import
{
Users
}
from
'
../../app/models
'
;
import
{
settings
}
from
'
../../app/settings
'
;
let
template
=
''
;
Meteor
.
startup
(()
=>
{
Mailer
.
getTemplateWrapped
(
'
Forgot_Password_Email
'
,
(
value
)
=>
{
template
=
value
;
});
});
Meteor
.
methods
({
sendForgotPasswordEmail
(
to
)
{
check
(
to
,
String
);
le
t
email
=
to
.
trim
();
cons
t
email
=
to
.
trim
();
const
user
=
Users
.
findOneByEmailAddress
(
email
);
const
user
=
Users
.
findOneByEmailAddress
(
email
,
{
fields
:
{
_id
:
1
}
}
);
if
(
!
user
)
{
return
false
;
}
const
regex
=
new
RegExp
(
`^
${
s
.
escapeRegExp
(
email
)
}
$`
,
'
i
'
);
email
=
(
user
.
emails
||
[]).
map
((
item
)
=>
item
.
address
).
find
((
userEmail
)
=>
regex
.
test
(
userEmail
));
const
subject
=
Mailer
.
replace
(
settings
.
get
(
'
Forgot_Password_Email_Subject
'
)
||
''
,
{
name
:
user
.
name
,
email
,
});
const
html
=
Mailer
.
replace
(
template
,
{
name
:
user
.
name
,
email
,
});
Accounts
.
emailTemplates
.
from
=
`
${
settings
.
get
(
'
Site_Name
'
)
}
<
${
settings
.
get
(
'
From_Email
'
)
}
>`
;
try
{
Accounts
.
emailTemplates
.
resetPassword
.
subject
=
function
(
/* userModel*/
)
{
return
subject
;
// TODO check a better way to do this
};
Accounts
.
emailTemplates
.
resetPassword
.
html
=
function
(
userModel
,
url
)
{
return
Mailer
.
replacekey
(
html
,
'
Forgot_Password_Url
'
,
url
);
};
return
!!
Accounts
.
sendResetPasswordEmail
(
user
.
_id
,
email
);
}
catch
(
error
)
{
throw
new
Meteor
.
Error
(
'
error-email-send-failed
'
,
`Error trying to send email:
${
error
.
message
}
`
,
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment