mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Refactor API authentication.
This commit is contained in:
parent
c33729e185
commit
5a4fc96ebc
13 changed files with 71 additions and 73 deletions
|
|
@ -15,13 +15,13 @@ const initialValues = {
|
|||
password: '',
|
||||
};
|
||||
|
||||
const validate = ({ userId, username, password }) => {
|
||||
const validate = ({ id, username, password }) => {
|
||||
const errors = {};
|
||||
|
||||
if (!username) {
|
||||
errors.username = <FormattedMessage id="label.required" defaultMessage="Required" />;
|
||||
}
|
||||
if (!userId && !password) {
|
||||
if (!id && !password) {
|
||||
errors.password = <FormattedMessage id="label.required" defaultMessage="Required" />;
|
||||
}
|
||||
|
||||
|
|
@ -33,8 +33,8 @@ export default function AccountEditForm({ values, onSave, onClose }) {
|
|||
const [message, setMessage] = useState();
|
||||
|
||||
const handleSubmit = async values => {
|
||||
const { userId } = values;
|
||||
const { ok, data } = await post(userId ? `/accounts/${userId}` : '/accounts', values);
|
||||
const { id } = values;
|
||||
const { ok, data } = await post(id ? `/accounts/${id}` : '/accounts', values);
|
||||
|
||||
if (ok) {
|
||||
onSave();
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ export default function WebsiteEditForm({ values, onSave, onClose }) {
|
|||
return (
|
||||
<FormLayout>
|
||||
<Formik
|
||||
initialValues={{ ...initialValues, ...values, enable_share_url: !!values?.shareId }}
|
||||
initialValues={{ ...initialValues, ...values, enableShareUrl: !!values?.shareId }}
|
||||
validate={validate}
|
||||
onSubmit={handleSubmit}
|
||||
>
|
||||
|
|
@ -128,7 +128,7 @@ export default function WebsiteEditForm({ values, onSave, onClose }) {
|
|||
<OwnerDropDown accounts={accounts} user={user} />
|
||||
<FormRow>
|
||||
<label />
|
||||
<Field name="enable_share_url">
|
||||
<Field name="enableShareUrl">
|
||||
{({ field }) => (
|
||||
<Checkbox
|
||||
{...field}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue