fix (akka-apps): Banned users being able to rejoin (when they have customdata) (#21210)

This commit is contained in:
Gustavo Trott 2024-09-18 09:43:21 -03:00 committed by GitHub
parent dda6f9f85b
commit 74fae992bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 24 deletions

View File

@ -55,23 +55,30 @@ trait RegisterUserReqMsgHdlr {
val guestStatus = msg.body.guestStatus val guestStatus = msg.body.guestStatus
val regUser = RegisteredUsers.create(msg.body.intUserId, msg.body.extUserId,
msg.body.name, msg.body.role, msg.body.authToken,
msg.body.avatarURL,
msg.body.webcamBackgroundURL,
ColorPicker.nextColor(liveMeeting.props.meetingProp.intId), msg.body.guest, msg.body.authed, guestStatus, msg.body.excludeFromDashboard, false)
checkUserConcurrentAccesses(regUser)
RegisteredUsers.add(liveMeeting.registeredUsers, regUser)
val userCustomData: Map[String, String] = msg.body.userCustomData.map { val userCustomData: Map[String, String] = msg.body.userCustomData.map {
case (k, v) => k -> v.toString case (k, v) => k -> v.toString
} }
if (userCustomData.nonEmpty) { val regUser = RegisteredUsers.create(
RegisteredUsers.updateUserCustomData(liveMeeting.registeredUsers, regUser, userCustomData) msg.body.intUserId,
} msg.body.extUserId,
msg.body.name,
msg.body.role,
msg.body.authToken,
msg.body.avatarURL,
msg.body.webcamBackgroundURL,
ColorPicker.nextColor(liveMeeting.props.meetingProp.intId),
msg.body.guest,
msg.body.authed,
guestStatus,
msg.body.excludeFromDashboard,
loggedOut = false,
userCustomData = userCustomData
)
checkUserConcurrentAccesses(regUser)
RegisteredUsers.add(liveMeeting.registeredUsers, regUser)
log.info("Register user success. meetingId=" + liveMeeting.props.meetingProp.intId log.info("Register user success. meetingId=" + liveMeeting.props.meetingProp.intId
+ " userId=" + msg.body.extUserId + " user=" + regUser) + " userId=" + msg.body.extUserId + " user=" + regUser)

View File

@ -21,6 +21,7 @@ trait ValidateAuthTokenReqMsgHdlr extends HandlerHelpers {
var failReasonCode = EjectReasonCode.VALIDATE_TOKEN var failReasonCode = EjectReasonCode.VALIDATE_TOKEN
log.info("Number of registered users [{}]", RegisteredUsers.numRegisteredUsers(liveMeeting.registeredUsers)) log.info("Number of registered users [{}]", RegisteredUsers.numRegisteredUsers(liveMeeting.registeredUsers))
val regUser = RegisteredUsers.getRegisteredUserWithToken(msg.body.authToken, msg.body.userId, val regUser = RegisteredUsers.getRegisteredUserWithToken(msg.body.authToken, msg.body.userId,
liveMeeting.registeredUsers) liveMeeting.registeredUsers)
regUser match { regUser match {

View File

@ -35,7 +35,7 @@ trait UserJoinedVoiceConfEvtMsgHdlr extends SystemConfiguration {
def registerUserInRegisteredUsers() = { def registerUserInRegisteredUsers() = {
val regUser = RegisteredUsers.create(msg.body.intId, msg.body.voiceUserId, val regUser = RegisteredUsers.create(msg.body.intId, msg.body.voiceUserId,
msg.body.callerIdName, Roles.VIEWER_ROLE, msg.body.intId, "", "", msg.body.callerIdName, Roles.VIEWER_ROLE, msg.body.intId, "", "",
userColor, true, true, GuestStatus.WAIT, true, false) userColor, true, true, GuestStatus.WAIT, true, false, Map.empty)
RegisteredUsers.add(liveMeeting.registeredUsers, regUser) RegisteredUsers.add(liveMeeting.registeredUsers, regUser)
} }

View File

@ -6,7 +6,7 @@ import org.bigbluebutton.core.domain.BreakoutRoom2x
object RegisteredUsers { object RegisteredUsers {
def create(userId: String, extId: String, name: String, roles: String, def create(userId: String, extId: String, name: String, roles: String,
token: String, avatar: String, webcamBackground: String, color: String, guest: Boolean, authenticated: Boolean, token: String, avatar: String, webcamBackground: String, color: String, guest: Boolean, authenticated: Boolean,
guestStatus: String, excludeFromDashboard: Boolean, loggedOut: Boolean): RegisteredUser = { guestStatus: String, excludeFromDashboard: Boolean, loggedOut: Boolean, userCustomData: Map[String, String]): RegisteredUser = {
new RegisteredUser( new RegisteredUser(
userId, userId,
extId, extId,
@ -25,6 +25,7 @@ object RegisteredUsers {
false, false,
false, false,
loggedOut, loggedOut,
userCustomData = userCustomData
) )
} }
@ -79,7 +80,6 @@ object RegisteredUsers {
} }
def add(users: RegisteredUsers, user: RegisteredUser): Vector[RegisteredUser] = { def add(users: RegisteredUsers, user: RegisteredUser): Vector[RegisteredUser] = {
findWithExternUserId(user.externId, users) match { findWithExternUserId(user.externId, users) match {
case Some(u) => case Some(u) =>
if (u.banned) { if (u.banned) {
@ -165,12 +165,6 @@ object RegisteredUsers {
u u
} }
def updateUserCustomData(users: RegisteredUsers, user: RegisteredUser, userCustomData: Map[String, String]): RegisteredUser = {
val u = user.modify(_.userCustomData).setTo(userCustomData)
users.save(u)
u
}
} }
class RegisteredUsers { class RegisteredUsers {

View File

@ -57,7 +57,7 @@ object FakeUserGenerator {
val color = "#ff6242" val color = "#ff6242"
val ru = RegisteredUsers.create(userId = id, extId, name, role, val ru = RegisteredUsers.create(userId = id, extId, name, role,
authToken, avatarURL, webcamBackgroundURL, color, guest, authed, guestStatus = GuestStatus.ALLOW, false, false) authToken, avatarURL, webcamBackgroundURL, color, guest, authed, guestStatus = GuestStatus.ALLOW, false, false, Map.empty)
RegisteredUsers.add(users, ru) RegisteredUsers.add(users, ru)
ru ru
} }