Browse Source

Add qs

main
Haris Razis 4 years ago
parent
commit
535140eded
  1. 14078
      web/package-lock.json
  2. 1
      web/package.json
  3. 3
      web/src/store/index.ts
  4. 5
      web/src/views/Login.vue

14078
web/package-lock.json

File diff suppressed because it is too large

1
web/package.json

@ -12,6 +12,7 @@
"bootstrap": "^5.0.0-beta1", "bootstrap": "^5.0.0-beta1",
"bulma": "^0.9.1", "bulma": "^0.9.1",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"qs": "^6.5.2",
"vue": "^3.0.0", "vue": "^3.0.0",
"vue-class-component": "^8.0.0-0", "vue-class-component": "^8.0.0-0",
"vue-router": "^4.0.0-0", "vue-router": "^4.0.0-0",

3
web/src/store/index.ts

@ -1,5 +1,6 @@
import {createStore} from 'vuex' import {createStore} from 'vuex'
import axios, {AxiosResponse} from "axios"; import axios, {AxiosResponse} from "axios";
import qs from 'qs'
export default createStore({ export default createStore({
state: { state: {
@ -22,7 +23,7 @@ export default createStore({
actions: { actions: {
login({commit}, user: { username: string, password: string }) { login({commit}, user: { username: string, password: string }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios({url: 'http://localhost:8000/auth/login', data: {user}, method: 'GET'}) axios({method: 'post', url: 'http://localhost:8000/auth/login', data: qs.stringify({user})})
.then((resp: AxiosResponse) => { .then((resp: AxiosResponse) => {
commit("auth_success", user); commit("auth_success", user);
resolve(resp) resolve(resp)

5
web/src/views/Login.vue

@ -53,10 +53,9 @@ export default class Login extends Vue {
private password = ''; private password = '';
private login() { private login() {
let email = this.username let user = {username: this.username, password: this.password}
let password = this.password
this.$store.dispatch('login', {email, password}) this.$store.dispatch('login', user)
.then(() => this.$router.push('/dashboard')) .then(() => this.$router.push('/dashboard'))
.catch((err: Error) => { .catch((err: Error) => {
console.log(err) console.log(err)

Loading…
Cancel
Save