Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit 462a0f4

Browse files
authored
Merge branch 'master' into fix/double-recaptcha
2 parents 6058651 + 529d02f commit 462a0f4

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

client/src/components/ctftime-additional.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Form from '../components/form'
2+
import useRecaptcha from '../components/recaptcha'
23
import config from '../config'
34
import withStyles from '../components/jss'
45
import { register } from '../api/auth'
@@ -28,28 +29,28 @@ export default withStyles({
2829
const handleNameChange = useCallback(e => setName(e.target.value), [])
2930

3031
const [errors, setErrors] = useState({})
32+
const requestRecaptchaCode = useRecaptcha('register')
3133

32-
const handleRegister = useCallback(() => {
34+
const handleRegister = useCallback(async () => {
3335
setDisabledButton(true)
3436

35-
register({
37+
const { errors } = await register({
3638
ctftimeToken,
3739
name: name || undefined,
38-
division
40+
division,
41+
recaptchaCode: await requestRecaptchaCode?.()
3942
})
40-
.then(({ errors }) => {
41-
setDisabledButton(false)
43+
setDisabledButton(false)
4244

43-
if (!errors) {
44-
return
45-
}
46-
if (errors.name) {
47-
setShowName(true)
48-
}
45+
if (!errors) {
46+
return
47+
}
48+
if (errors.name) {
49+
setShowName(true)
50+
}
4951

50-
setErrors(errors)
51-
})
52-
}, [ctftimeToken, name, division])
52+
setErrors(errors)
53+
}, [ctftimeToken, name, division, requestRecaptchaCode])
5354

5455
const handleSubmit = useCallback(e => {
5556
e.preventDefault()

client/src/components/graph.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ const pointsToPolyline = ({ id, name, currentScore, points, maxX, minX, maxY, wi
3838

3939
const getXLabels = ({ minX, maxX, width }) => {
4040
const labels = []
41+
const step = Math.ceil((maxX - minX) / width * 200 / day) * day
4142
let labelStart = new Date(minX).setHours(0, 0, 0, 0)
42-
if (labelStart % day !== 0) {
43-
labelStart += day
43+
if (labelStart % step !== 0) {
44+
labelStart += step
4445
}
4546

46-
for (let label = labelStart; label <= maxX; label += day) {
47+
for (let label = labelStart; label <= maxX; label += step) {
4748
labels.push({
4849
label: new Date(label).toLocaleDateString(),
4950
x: timeToX({ minX, maxX, time: label, width })

server/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ app.register(helmet, {
4141
directives: {
4242
defaultSrc: ['\'none\''],
4343
styleSrc: ['\'unsafe-inline\'', '\'self\''],
44-
scriptSrc: ['\'self\'', 'https://www.google-analytics.com'],
44+
scriptSrc: ['\'self\'', 'https://www.google-analytics.com', 'https://www.google.com/recaptcha/', 'https://www.gstatic.com/recaptcha/'],
45+
frameSrc: ['https://www.google.com/recaptcha/'],
4546
connectSrc: ['\'self\'', 'https://www.google-analytics.com'],
4647
imgSrc: ['*', 'data:']
4748
}

0 commit comments

Comments
 (0)