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
483b4a39
Unverified
Commit
483b4a39
authored
1 month ago
by
Marcos Spessatto Defendi
Committed by
GitHub
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor: remove calls for setEmail Meteor method (server) (#34889)
parent
8c51b5e9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/meteor/app/lib/server/methods/setEmail.ts
+25
-20
25 additions, 20 deletions
apps/meteor/app/lib/server/methods/setEmail.ts
apps/meteor/server/methods/saveUserProfile.ts
+3
-2
3 additions, 2 deletions
apps/meteor/server/methods/saveUserProfile.ts
with
28 additions
and
22 deletions
apps/meteor/app/lib/server/methods/setEmail.ts
+
25
−
20
View file @
483b4a39
import
type
{
IUser
}
from
'
@rocket.chat/core-typings
'
;
import
type
{
ServerMethods
}
from
'
@rocket.chat/ddp-client
'
;
import
{
check
}
from
'
meteor/check
'
;
import
{
Meteor
}
from
'
meteor/meteor
'
;
...
...
@@ -13,34 +14,38 @@ declare module '@rocket.chat/ddp-client' {
}
}
export
const
setEmailFunction
=
async
(
email
:
string
,
user
:
Meteor
.
User
|
IUser
)
=>
{
check
(
email
,
String
);
if
(
!
settings
.
get
(
'
Accounts_AllowEmailChange
'
))
{
throw
new
Meteor
.
Error
(
'
error-action-not-allowed
'
,
'
Changing email is not allowed
'
,
{
method
:
'
setEmail
'
,
action
:
'
Changing_email
'
,
});
}
if
(
user
.
emails
?.[
0
]
&&
user
.
emails
[
0
].
address
===
email
)
{
return
email
;
}
if
(
!
(
await
setEmail
(
user
.
_id
,
email
)))
{
throw
new
Meteor
.
Error
(
'
error-could-not-change-email
'
,
'
Could not change email
'
,
{
method
:
'
setEmail
'
,
});
}
return
email
;
};
Meteor
.
methods
<
ServerMethods
>
({
async
setEmail
(
email
)
{
check
(
email
,
String
);
const
user
=
await
Meteor
.
userAsync
();
if
(
!
user
)
{
throw
new
Meteor
.
Error
(
'
error-invalid-user
'
,
'
Invalid user
'
,
{
method
:
'
setEmail
'
});
}
if
(
!
settings
.
get
(
'
Accounts_AllowEmailChange
'
))
{
throw
new
Meteor
.
Error
(
'
error-action-not-allowed
'
,
'
Changing email is not allowed
'
,
{
method
:
'
setEmail
'
,
action
:
'
Changing_email
'
,
});
}
if
(
user
.
emails
?.[
0
]
&&
user
.
emails
[
0
].
address
===
email
)
{
return
email
;
}
if
(
!
(
await
setEmail
(
user
.
_id
,
email
)))
{
throw
new
Meteor
.
Error
(
'
error-could-not-change-email
'
,
'
Could not change email
'
,
{
method
:
'
setEmail
'
,
});
}
return
email
;
return
setEmailFunction
(
email
,
user
);
},
});
...
...
This diff is collapsed.
Click to expand it.
apps/meteor/server/methods/saveUserProfile.ts
+
3
−
2
View file @
483b4a39
...
...
@@ -11,6 +11,7 @@ import { saveCustomFields } from '../../app/lib/server/functions/saveCustomField
import
{
validateUserEditing
}
from
'
../../app/lib/server/functions/saveUser
'
;
import
{
saveUserIdentity
}
from
'
../../app/lib/server/functions/saveUserIdentity
'
;
import
{
passwordPolicy
}
from
'
../../app/lib/server/lib/passwordPolicy
'
;
import
{
setEmailFunction
}
from
'
../../app/lib/server/methods/setEmail
'
;
import
{
settings
as
rcSettings
}
from
'
../../app/settings/server
'
;
import
{
setUserStatusMethod
}
from
'
../../app/user-status/server/methods/setUserStatus
'
;
import
{
compareUserPassword
}
from
'
../lib/compareUserPassword
'
;
...
...
@@ -107,8 +108,8 @@ async function saveUserProfile(
await
Users
.
setNickname
(
user
.
_id
,
settings
.
nickname
.
trim
());
}
if
(
settings
.
email
)
{
await
Meteor
.
callAsync
(
'
setEmail
'
,
settings
.
email
);
if
(
user
&&
settings
.
email
)
{
await
setEmailFunction
(
settings
.
email
,
user
);
}
const
canChangePasswordForOAuth
=
rcSettings
.
get
<
boolean
>
(
'
Accounts_AllowPasswordChangeForOAuthUsers
'
);
...
...
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