Created
November 3, 2017 16:00
-
-
Save IamManchanda/e1f205b98c8e9b7d1954df5bbf62e0ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Validator } from 'vee-validate'; | |
| import loginMixin from '../mixins/login'; | |
| import validateMixin from '../mixins/validate'; | |
| export default { | |
| name: 'signup', | |
| validator: null, | |
| errors: null, | |
| mixins: [loginMixin, validateMixin], | |
| data() { | |
| return { | |
| name: '', | |
| email: '', | |
| password: '', | |
| isVisible: false, | |
| }; | |
| }, | |
| watch: { | |
| email(value) { | |
| this.validator.validate('email', value); | |
| }, | |
| }, | |
| methods: { | |
| doSignup() { | |
| this.$validator.validateAll().then(() => { | |
| this.isVisible = true; | |
| const { name, email, password } = this; | |
| this.register(name, email, password).then(() => { | |
| this.$router.push({ | |
| name: 'profile', | |
| }); | |
| }).catch((error) => { | |
| // eslint-disable-next-line | |
| console.log(error); | |
| }); | |
| }); | |
| }, | |
| }, | |
| created() { | |
| this.validator = new Validator({ | |
| email: 'required|email', | |
| }); | |
| this.$set(this, 'errors', this.validator.errors); | |
| }, | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment