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
70b0e919
Commit
70b0e919
authored
9 years ago
by
Nberton
Browse files
Options
Downloads
Patches
Plain Diff
Fixed Issue #1468
parent
01b4ed79
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/rocketchat-lib/server/functions/setUsername.coffee
+8
-4
8 additions, 4 deletions
packages/rocketchat-lib/server/functions/setUsername.coffee
packages/rocketchat-lib/server/methods/setUsername.coffee
+7
-2
7 additions, 2 deletions
packages/rocketchat-lib/server/methods/setUsername.coffee
with
15 additions
and
6 deletions
packages/rocketchat-lib/server/functions/setUsername.coffee
+
8
−
4
View file @
70b0e919
RocketChat
.
setUsername
=
(
user
,
username
)
->
RocketChat
.
setUsername
=
(
user
,
username
)
->
console
.
log
(
"In setUserName"
)
username
=
s
.
trim
username
username
=
s
.
trim
username
if
not
user
or
not
username
if
not
user
or
not
username
return
false
return
false
...
@@ -10,12 +11,15 @@ RocketChat.setUsername = (user, username) ->
...
@@ -10,12 +11,15 @@ RocketChat.setUsername = (user, username) ->
if
user
.
username
is
username
if
user
.
username
is
username
return
user
return
user
# Check username availability
unless
RocketChat
.
checkUsernameAvailability
username
return
false
previousUsername
=
user
.
username
previousUsername
=
user
.
username
# Check username availability or if the user already owns a different casing of the name
if
(
!
previousUsername
or
!
(
username
.
toLowerCase
()
==
previousUsername
.
toLowerCase
()))
unless
RocketChat
.
checkUsernameAvailability
username
return
false
# If first time setting username, send Enrollment Email
# If first time setting username, send Enrollment Email
if
not
previousUsername
and
RocketChat
.
settings
.
get
'Accounts_Enrollment_Email'
if
not
previousUsername
and
RocketChat
.
settings
.
get
'Accounts_Enrollment_Email'
Accounts
.
sendEnrollmentEmail
(
user
.
_id
)
Accounts
.
sendEnrollmentEmail
(
user
.
_id
)
...
...
This diff is collapsed.
Click to expand it.
packages/rocketchat-lib/server/methods/setUsername.coffee
+
7
−
2
View file @
70b0e919
...
@@ -16,8 +16,13 @@ Meteor.methods
...
@@ -16,8 +16,13 @@ Meteor.methods
if
not
/^[0-9a-zA-Z-_.]+$/
.
test
username
if
not
/^[0-9a-zA-Z-_.]+$/
.
test
username
throw
new
Meteor
.
Error
'username-invalid'
,
"
#{
username
}
is not a valid username, use only letters, numbers, dots and dashes"
throw
new
Meteor
.
Error
'username-invalid'
,
"
#{
username
}
is not a valid username, use only letters, numbers, dots and dashes"
if
not
RocketChat
.
checkUsernameAvailability
username
if
user
.
username
!=
undefined
throw
new
Meteor
.
Error
'username-unavailable'
,
"
#{
username
}
is already in use :("
if
not
username
.
toLowerCase
()
==
user
.
username
.
toLowerCase
()
if
not
RocketChat
.
checkUsernameAvailability
username
throw
new
Meteor
.
Error
'username-unavailable'
,
"
#{
username
}
is already in use :("
else
if
not
RocketChat
.
checkUsernameAvailability
username
throw
new
Meteor
.
Error
'username-unavailable'
,
"
#{
username
}
is already in use :("
unless
RocketChat
.
setUsername
user
,
username
unless
RocketChat
.
setUsername
user
,
username
throw
new
Meteor
.
Error
'could-not-change-username'
,
"Could not change username"
throw
new
Meteor
.
Error
'could-not-change-username'
,
"Could not change username"
...
...
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