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.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js
new file mode 100644
index 00000000..771b3b27
--- /dev/null
+++ b/src/components/registration/registration.js
@@ -0,0 +1,37 @@
+const registration = {
+ data: () => ({
+ user: {},
+ error: false,
+ registering: false
+ }),
+ created () {
+ if (!this.$store.state.config.registrationOpen || !!this.$store.state.users.currentUser) {
+ this.$router.push('/main/all')
+ }
+ },
+ computed: {
+ termsofservice () { return this.$store.state.config.tos }
+ },
+ 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