+
+
-
{{ form.password1.errors }}
-
+
+
-
{{ form.password2.errors }}
+
-
@@ -54,7 +71,8 @@
- Already have an account? Login
+ Already have an account?
+ Login
@@ -73,16 +91,73 @@ export default {
data() {
return {
msg: 'Register',
+ password2: '',
form: {
username: '',
+ domain: '',
email: '',
- password1: '',
- password2: '',}
+ password: '',
+ },
+ errors: {
+ username: null,
+ domain: null,
+ email: null,
+ password: null,
+ password2: null,
+ },
+ domains: []
}
+ },
+ methods: {
+ do_register() {
+ console.log('do_register');
+ console.log(this.form);
+ if (this.form.password !== this.password2) {
+ this.errors.password2 = 'Passwords do not match';
+ return;
+ } else {
+ this.errors.password2 = null;
+ }
+ fetch('/auth/register/', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(this.form)
+ })
+ .then(response => response.json())
+ .then(data => {
+ if (data.errors) {
+ console.error('Error:', data.errors);
+ this.errors = data.errors;
+ return;
+ }
+ console.log('Success:', data);
+ this.msg = 'Success';
+ this.$router.push('/login');
+ })
+ .catch((error) => {
+ console.error('Error:', error);
+ this.msg = 'Error';
+ });
+ }
+ },
+ mounted() {
+ fetch('/api/domains/')
+ .then(response => response.json())
+ .then(data => {
+ this.domains = data;
+ });
}
}
\ No newline at end of file
diff --git a/frontend/vite.config.js b/frontend/vite.config.js
index 40c16c4..1c3c751 100644
--- a/frontend/vite.config.js
+++ b/frontend/vite.config.js
@@ -20,9 +20,23 @@ export default defineConfig({
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Origin, Content-Type, X-Auth-Token, Authorization, Accept,charset,boundary,Content-Length',
'Access-Control-Allow-Credentials': 'true'
-
-
-
+ },
+ proxy: {
+ '^/api/': {
+ target: "http://127.0.0.1:8000/",
+ },
+ '^/auth/': {
+ target: "http://127.0.0.1:8000/",
+ },
+ '^/admin/': {
+ target: "http://127.0.0.1:8000/",
+ },
+ '^/docs/': {
+ target: "http://127.0.0.1:8000/",
+ },
+ '^/static/': {
+ target: "http://127.0.0.1:8000/",
+ }
}
}
})