This commit is contained in:
Athou
2024-08-07 08:10:14 +02:00
parent 2f6ddf0e70
commit cc32f8ad16
164 changed files with 2011 additions and 3288 deletions

View File

@@ -80,7 +80,7 @@
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/assets</outputDirectory>
<outputDirectory>${project.build.directory}/classes/META-INF/resources</outputDirectory>
<resources>
<resource>
<directory>dist</directory>

View File

@@ -81,7 +81,17 @@ export const client = {
},
},
user: {
login: async (req: LoginRequest) => await axiosInstance.post("user/login", req),
login: async (req: LoginRequest) => {
const formData = new URLSearchParams()
formData.append("j_username", req.name)
formData.append("j_password", req.password)
return await axiosInstance.post("j_security_check", formData, {
baseURL: ".",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
})
},
register: async (req: RegistrationRequest) => await axiosInstance.post("user/register", req),
passwordReset: async (req: PasswordResetRequest) => await axiosInstance.post("user/passwordReset", req),
getSettings: async () => await axiosInstance.get<Settings>("user/settings"),

View File

@@ -24,12 +24,18 @@ export function RegistrationPage() {
},
})
const register = useAsyncCallback(client.user.register, {
const login = useAsyncCallback(client.user.login, {
onSuccess: () => {
dispatch(redirectToRootCategory())
},
})
const register = useAsyncCallback(client.user.register, {
onSuccess: () => {
login.execute(form.values)
},
})
return (
<Container size="xs">
<PageTitle />
@@ -50,6 +56,12 @@ export function RegistrationPage() {
</Box>
)}
{login.error && (
<Box mb="md">
<Alert messages={errorToStrings(login.error)} />
</Box>
)}
<form onSubmit={form.onSubmit(register.execute)}>
<Stack>
<TextInput label="User Name" placeholder="User Name" {...form.getInputProps("name")} size="md" required />
@@ -68,7 +80,7 @@ export function RegistrationPage() {
size="md"
required
/>
<Button type="submit" loading={register.loading}>
<Button type="submit" loading={register.loading || login.loading}>
<Trans>Sign up</Trans>
</Button>
<Center>

View File

@@ -32,6 +32,7 @@ export default defineConfig(env => ({
"/openapi.json": "http://localhost:8083",
"/custom_css.css": "http://localhost:8083",
"/custom_js.js": "http://localhost:8083",
"/j_security_check": "http://localhost:8083",
"/logout": "http://localhost:8083",
},
},