1
0

Added register page

This commit is contained in:
konrad
2018-09-08 22:27:13 +02:00
parent 6ec92f68e5
commit 46aec7b4ca
4 changed files with 138 additions and 4 deletions

View File

@ -44,6 +44,29 @@ export default {
})
},
register (context, creds, redirect) {
HTTP.post('register', {
username: creds.username,
email: creds.email,
password: creds.password
})
.then(response => {
// eslint-disable-next-line
console.log(response)
this.login(context, creds, redirect)
})
.catch(e => {
// Hide the loader
context.loading = false
if (e.response) {
context.error = e.response.data.message
if (e.response.status === 401) {
context.error = 'Wrong username or password.'
}
}
})
},
logout () {
localStorage.removeItem('token')
router.push({ name: 'login' })