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
58a0c20a
Unverified
Commit
58a0c20a
authored
4 years ago
by
pierre-lehnen-rc
Committed by
Diego Sampaio
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] Errors in LDAP avatar sync preventing login (#18948)
parent
a4fc7864
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/ldap/server/sync.js
+35
-27
35 additions, 27 deletions
app/ldap/server/sync.js
with
35 additions
and
27 deletions
app/ldap/server/sync.js
+
35
−
27
View file @
58a0c20a
...
...
@@ -337,6 +337,40 @@ export function mapLDAPGroupsToChannels(ldap, ldapUser, user) {
return
userChannels
;
}
function
syncUserAvatar
(
user
,
ldapUser
)
{
if
(
!
user
?.
_id
||
settings
.
get
(
'
LDAP_Sync_User_Avatar
'
)
!==
true
)
{
return
;
}
const
avatarField
=
(
settings
.
get
(
'
LDAP_Avatar_Field
'
)
||
'
thumbnailPhoto
'
).
trim
();
const
avatar
=
ldapUser
.
_raw
[
avatarField
]
||
ldapUser
.
_raw
.
thumbnailPhoto
||
ldapUser
.
_raw
.
jpegPhoto
;
if
(
!
avatar
)
{
return
;
}
logger
.
info
(
'
Syncing user avatar
'
);
Meteor
.
defer
(()
=>
{
const
rs
=
RocketChatFile
.
bufferToStream
(
avatar
);
const
fileStore
=
FileUpload
.
getStore
(
'
Avatars
'
);
fileStore
.
deleteByName
(
user
.
username
);
const
file
=
{
userId
:
user
.
_id
,
type
:
'
image/jpeg
'
,
};
Meteor
.
runAsUser
(
user
.
_id
,
()
=>
{
fileStore
.
insert
(
file
,
rs
,
(
err
,
result
)
=>
{
Meteor
.
setTimeout
(
function
()
{
Users
.
setAvatarData
(
user
.
_id
,
'
ldap
'
,
result
.
etag
);
Notifications
.
notifyLogged
(
'
updateAvatar
'
,
{
username
:
user
.
username
,
etag
:
result
.
etag
});
},
500
);
});
});
});
}
export
function
syncUserData
(
user
,
ldapUser
,
ldap
)
{
logger
.
info
(
'
Syncing user data
'
);
logger
.
debug
(
'
user
'
,
{
email
:
user
.
email
,
_id
:
user
.
_id
});
...
...
@@ -397,33 +431,7 @@ export function syncUserData(user, ldapUser, ldap) {
}
}
const
avatarField
=
(
settings
.
get
(
'
LDAP_Avatar_Field
'
)
||
'
thumbnailPhoto
'
).
trim
();
if
(
user
&&
user
.
_id
&&
settings
.
get
(
'
LDAP_Sync_User_Avatar
'
)
===
true
)
{
const
avatar
=
ldapUser
.
_raw
[
avatarField
]
||
ldapUser
.
_raw
.
thumbnailPhoto
||
ldapUser
.
_raw
.
jpegPhoto
;
if
(
avatar
)
{
logger
.
info
(
'
Syncing user avatar
'
);
const
rs
=
RocketChatFile
.
bufferToStream
(
avatar
);
const
fileStore
=
FileUpload
.
getStore
(
'
Avatars
'
);
fileStore
.
deleteByName
(
user
.
username
);
const
file
=
{
userId
:
user
.
_id
,
type
:
'
image/jpeg
'
,
};
Meteor
.
runAsUser
(
user
.
_id
,
()
=>
{
fileStore
.
insert
(
file
,
rs
,
(
err
,
result
)
=>
{
Meteor
.
setTimeout
(
function
()
{
Users
.
setAvatarData
(
user
.
_id
,
'
ldap
'
,
result
.
etag
);
Notifications
.
notifyLogged
(
'
updateAvatar
'
,
{
username
:
user
.
username
,
etag
:
result
.
etag
});
},
500
);
});
});
}
}
syncUserAvatar
(
user
,
ldapUser
);
}
export
function
addLdapUser
(
ldapUser
,
username
,
password
,
ldap
)
{
...
...
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