aboutsummaryrefslogtreecommitdiff
path: root/src/components/registration/registration.js
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-04-15 18:12:23 +0200
committerRoger Braun <roger@rogerbraun.net>2017-04-15 18:29:46 +0200
commita766e886f529a3f602ebacf70d7944678c027414 (patch)
tree1d74599d4174758e7fb2e773c86edddd96f79081 /src/components/registration/registration.js
parent6d7fcb057d7578ed33c556641a4ff25c6be74d4e (diff)
Add a registration form.
Diffstat (limited to 'src/components/registration/registration.js')
-rw-r--r--src/components/registration/registration.js29
1 files changed, 29 insertions, 0 deletions
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