Skip to content

Commit d41b86f

Browse files
committed
Correctly pass along allowed IPs for client API keys, closes pterodactyl#2244
1 parent a6cc537 commit d41b86f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,14 @@ public function rules(): array
1717
'allowed_ips.*' => 'ip',
1818
];
1919
}
20+
21+
/**
22+
* @return array|string[]
23+
*/
24+
public function messages()
25+
{
26+
return [
27+
'allowed_ips.*' => 'All of the IP addresses entered must be valid IPv4 addresses.',
28+
];
29+
}
2030
}

resources/scripts/components/dashboard/forms/CreateApiKeyForm.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ import { ApiKey } from '@/api/account/getApiKeys';
1212
import tw from 'twin.macro';
1313
import Button from '@/components/elements/Button';
1414
import Input, { Textarea } from '@/components/elements/Input';
15+
import styled from 'styled-components/macro';
1516

1617
interface Values {
1718
description: string;
1819
allowedIps: string;
1920
}
2021

22+
const CustomTextarea = styled(Textarea)`${tw`h-32`}`;
23+
2124
export default ({ onKeyCreated }: { onKeyCreated: (key: ApiKey) => void }) => {
2225
const [ apiKey, setApiKey ] = useState('');
2326
const { addError, clearFlashes } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
@@ -66,10 +69,7 @@ export default ({ onKeyCreated }: { onKeyCreated: (key: ApiKey) => void }) => {
6669
</Modal>
6770
<Formik
6871
onSubmit={submit}
69-
initialValues={{
70-
description: '',
71-
allowedIps: '',
72-
}}
72+
initialValues={{ description: '', allowedIps: '' }}
7373
validationSchema={object().shape({
7474
allowedIps: string(),
7575
description: string().required().min(4),
@@ -91,7 +91,7 @@ export default ({ onKeyCreated }: { onKeyCreated: (key: ApiKey) => void }) => {
9191
name={'allowedIps'}
9292
description={'Leave blank to allow any IP address to use this API key, otherwise provide each IP address on a new line.'}
9393
>
94-
<Field as={Textarea} name={'allowedIps'} css={tw`h-32`}/>
94+
<Field name={'allowedIps'} as={CustomTextarea}/>
9595
</FormikFieldWrapper>
9696
<div css={tw`flex justify-end mt-6`}>
9797
<Button>Create</Button>

0 commit comments

Comments
 (0)