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

hotfix - twilio ddos fix #9237

Merged
merged 4 commits into from
Jun 30, 2021
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
6 changes: 3 additions & 3 deletions app/assets/v2/js/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const makeMenu = (navbarEl) => {
};

// pull computedRootStyles from shared.js or compute here
const computedRootStyles = (window.hasOwnProperty("computedRootStyles") ? window.computedRootStyles : getComputedStyle(document.documentElement));
const computedRootStyles = (Object.hasOwnProperty.call(window, 'computedRootStyles') ? window.computedRootStyles : getComputedStyle(document.documentElement));

// pull breakpoint_md from shared.js or from root styles if not present
const breakpoint_md = (window.hasOwnProperty("breakpoint_md") ? window.breakpoint_md : parseFloat(computedRootStyles.getPropertyValue('--breakpoint-md')));
const breakpoint_md = (Object.hasOwnProperty.call(window, 'breakpoint_md') ? window.breakpoint_md : parseFloat(computedRootStyles.getPropertyValue('--breakpoint-md')));

// read the transition duration from navbar.scss (computedRootStyles is defined in shared.js)
const transitionDuration = parseFloat(computedRootStyles.getPropertyValue('--gc-menu-transition-duration'));
Expand Down Expand Up @@ -199,7 +199,7 @@ const makeMenu = (navbarEl) => {
menuContainerEl.classList.remove('open');
// remove .show after the transitions finishes
setTimeout(() => {
menuContainerEl.classList.remove('show');
menuContainerEl.classList.remove('show');
}, transitionDuration);
};

Expand Down
18 changes: 15 additions & 3 deletions app/assets/v2/js/pages/profile-trust.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ Vue.component('sms-verify-modal', {
vm.service.is_verified = true;
vm.forceStep = 'validation-complete';
}).catch((e) => {
vm.errorMessage = e.responseJSON.msg;
if (e.status == 403) {
vm.errorMessage = e.responseText;
} else {
vm.errorMessage = e.responseJSON.msg;
}
});
}
},
Expand Down Expand Up @@ -237,7 +241,11 @@ Vue.component('sms-verify-modal', {
this.countdown();
this.display_email_option = response.allow_email;
}).catch((e) => {
vm.errorMessage = e.responseJSON.msg;
if (e.status == 403) {
vm.errorMessage = e.responseText;
} else {
vm.errorMessage = e.responseJSON.msg;
}
});
}
},
Expand All @@ -260,7 +268,11 @@ Vue.component('sms-verify-modal', {
this.countdown();
this.display_email_option = response.allow_email;
}).catch((e) => {
vm.errorMessage = e.responseJSON.msg;
if (e.status == 403) {
vm.errorMessage = e.responseText;
} else {
vm.errorMessage = e.responseJSON.msg;
}
});
}
},
Expand Down
2 changes: 2 additions & 0 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6811,6 +6811,7 @@ def validate_number(user, twilio, phone, redis, delivery_method='sms'):


@login_required
@ratelimit(key='ip', rate='2/m', method=ratelimit.UNSAFE, block=True)
def send_verification(request, handle):
is_logged_in_user = request.user.is_authenticated and request.user.username.lower() == handle.lower()
if not is_logged_in_user:
Expand Down Expand Up @@ -6863,6 +6864,7 @@ def send_verification(request, handle):


@login_required
@ratelimit(key='ip', rate='10/m', method=ratelimit.UNSAFE, block=True)
def validate_verification(request, handle):
is_logged_in_user = request.user.is_authenticated and request.user.username.lower() == handle.lower()
if not is_logged_in_user:
Expand Down
4 changes: 2 additions & 2 deletions app/tdi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from django.contrib.admin.views.decorators import staff_member_required
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.http import HttpResponse
from django.http import HttpResponse, HttpResponseForbidden
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.utils import translation
Expand All @@ -45,7 +45,7 @@


def ratelimited(request, ratelimited=False):
return whitepaper_access(request, ratelimited=True)
return HttpResponseForbidden("You're ratelimited - Please try again soon", 403)


@ratelimit(key='ip', rate='5/m', method=ratelimit.UNSAFE, block=True)
Expand Down