Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/8922 captcha #10

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions JitsiConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
* @returns {string}
* @static
*/
JitsiConference.resourceCreator = function(jid, isAuthenticatedUser) {

Check failure on line 347 in JitsiConference.js

View workflow job for this annotation

GitHub Actions / Build

'jid' is defined but never used

Check failure on line 347 in JitsiConference.js

View workflow job for this annotation

GitHub Actions / Build

'isAuthenticatedUser' is defined but never used
return RandomUtil.randomHexString(8).toLowerCase();
};

Expand Down Expand Up @@ -569,9 +569,9 @@
* @param replaceParticipant {boolean} whether the current join replaces
* an existing participant with same jwt from the meeting.
*/
JitsiConference.prototype.join = function(password, replaceParticipant = false) {
JitsiConference.prototype.join = function(password, replaceParticipant = false, captchaId, captchaValue) {
if (this.room) {
this.room.join(password, replaceParticipant).then(() => this._maybeSetSITimeout());
this.room.join(password, replaceParticipant, captchaId, captchaValue).then(() => this._maybeSetSITimeout());
}
};

Expand Down
19 changes: 17 additions & 2 deletions modules/xmpp/ChatRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ export default class ChatRoom extends Listenable {
* @returns {Promise} - resolved when join completes. At the time of this
* writing it's never rejected.
*/
join(password, replaceParticipant) {
join(password, replaceParticipant, captchaId, captchaValue) {
this.password = password;
this.captchaId = captchaId;
this.captchaValue = captchaValue;
this.replaceParticipant = replaceParticipant;

return new Promise(resolve => {
Expand Down Expand Up @@ -268,6 +270,8 @@ export default class ChatRoom extends Listenable {

if (this.password) {
pres.c('password').t(this.password).up();
pres.c('captchaId').t(this.captchaId).up();
pres.c('captchaValue').t(this.captchaValue).up();
}
if (this.options.billingId) {
pres.c('billingid').t(this.options.billingId).up();
Expand Down Expand Up @@ -1289,7 +1293,18 @@ export default class ChatRoom extends Listenable {
+ 'xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]')
.length) {
logger.log('on password required', from);
this.eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED);
let msg;

if ($(pres)
.find('>error[type="auth"]>text')?.length) {

msg = $(pres)
.find('>error[type="auth"]>text').text();

}
msg ? this.eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED, msg)
: this.eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED);

} else if ($(pres)
.find(
'>error[type="cancel"]'
Expand Down
Loading