From a766e886f529a3f602ebacf70d7944678c027414 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 15 Apr 2017 18:12:23 +0200 Subject: Add a registration form. --- src/components/login_form/login_form.vue | 3 + .../post_status_form/post_status_form.vue | 24 +++--- src/components/registration/registration.js | 29 ++++++++ src/components/registration/registration.vue | 86 ++++++++++++++++++++++ 4 files changed, 130 insertions(+), 12 deletions(-) create mode 100644 src/components/registration/registration.js create mode 100644 src/components/registration/registration.vue (limited to 'src/components') diff --git a/src/components/login_form/login_form.vue b/src/components/login_form/login_form.vue index b2fa5341..bf3f24e7 100644 --- a/src/components/login_form/login_form.vue +++ b/src/components/login_form/login_form.vue @@ -20,6 +20,9 @@
{{authError}}
+
+ Register new account +
diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 07280a41..e7143b62 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -63,6 +63,18 @@ } } + + .btn { + cursor: pointer; + } + + .btn[disabled] { + cursor: not-allowed; + } + + .icon-cancel { + cursor: pointer; + } form { display: flex; flex-direction: column; @@ -85,18 +97,6 @@ padding: 5px; resize: vertical; } - - .btn { - cursor: pointer; - } - - .btn[disabled] { - cursor: not-allowed; - } - - .icon-cancel { - cursor: pointer; - } } diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js new file mode 100644 index 00000000..93be9baa --- /dev/null +++ b/src/components/registration/registration.js @@ -0,0 +1,29 @@ +const registration = { + data: () => ({ + user: {}, + error: false, + registering: false + }), + methods: { + submit () { + this.registering = true + this.user.nickname = this.user.username + this.$store.state.api.backendInteractor.register(this.user).then( + (response) => { + if (response.ok) { + this.$store.dispatch('loginUser', this.user) + this.$router.push('/main/all') + this.registering = false + } else { + this.registering = false + response.json().then((data) => { + this.error = data.error + }) + } + } + ) + } + } +} + +export default registration diff --git a/src/components/registration/registration.vue b/src/components/registration/registration.vue new file mode 100644 index 00000000..b93b6cb3 --- /dev/null +++ b/src/components/registration/registration.vue @@ -0,0 +1,86 @@ + + + + -- cgit v1.2.3-70-g09d2