mirror of
https://github.com/owncast/owncast.git
synced 2024-11-23 05:14:20 +03:00
fix a merge conflict
This commit is contained in:
parent
63e25fae3f
commit
f06325c11c
1 changed files with 23 additions and 2 deletions
|
@ -35,8 +35,26 @@ const saveKeys = async (keys, setError) => {
|
|||
}
|
||||
};
|
||||
|
||||
const generateRndKey = () => {
|
||||
let defaultKey = '';
|
||||
let isValidStreamKey = false;
|
||||
const streamKeyRegex = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#$%^&*]).{8,192}$/;
|
||||
const s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*';
|
||||
|
||||
while (!isValidStreamKey) {
|
||||
const temp = Array.apply(20, Array(30))
|
||||
.map(() => s.charAt(Math.floor(Math.random() * s.length)))
|
||||
.join('');
|
||||
if (streamKeyRegex.test(temp)) {
|
||||
isValidStreamKey = true;
|
||||
defaultKey = temp;
|
||||
}
|
||||
}
|
||||
return defaultKey;
|
||||
};
|
||||
|
||||
const AddKeyForm = ({ setShowAddKeyForm, setFieldInConfigState, streamKeys, setError }) => {
|
||||
const [hasChanged, setHasChanged] = useState(false);
|
||||
const [hasChanged, setHasChanged] = useState(true);
|
||||
const [form] = Form.useForm();
|
||||
const { Item } = Form;
|
||||
// Password Complexity rules
|
||||
|
@ -70,6 +88,9 @@ const AddKeyForm = ({ setShowAddKeyForm, setFieldInConfigState, streamKeys, setE
|
|||
}
|
||||
};
|
||||
|
||||
// Default auto-generated key
|
||||
const defaultKey = generateRndKey();
|
||||
|
||||
return (
|
||||
<Form
|
||||
layout="horizontal"
|
||||
|
@ -91,7 +112,7 @@ const AddKeyForm = ({ setShowAddKeyForm, setFieldInConfigState, streamKeys, setE
|
|||
}
|
||||
rules={PASSWORD_COMPLEXITY_RULES}
|
||||
>
|
||||
<Input onChange={handleInputChange} />
|
||||
<Input placeholder="def456" defaultValue={defaultKey} onChange={handleInputChange} />
|
||||
</Item>
|
||||
<Item
|
||||
style={{ width: '60%', marginRight: '5px' }}
|
||||
|
|
Loading…
Reference in a new issue