aboutsummaryrefslogtreecommitdiff
path: root/src/components/registration/registration.js
diff options
context:
space:
mode:
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