Mercurial > gemma
comparison client/src/stores/user.js @ 484:2ac37419f593
Implemented wamos/issue114 (Improve code consistency: For login use json body, disallow GET).
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 24 Aug 2018 11:36:11 +0200 |
parents | 516f0f84fe39 |
children | 04a6bea229e4 |
comparison
equal
deleted
inserted
replaced
483:27502291e564 | 484:2ac37419f593 |
---|---|
1 import { HTTP } from "../lib/http"; | 1 import { HTTP } from "../lib/http"; |
2 import qs from "qs"; | |
3 | 2 |
4 const User = { | 3 const User = { |
5 namespaced: true, | 4 namespaced: true, |
6 state: { | 5 state: { |
7 authenticated: false, | 6 authenticated: false, |
64 actions: { | 63 actions: { |
65 login({ commit }, user) { | 64 login({ commit }, user) { |
66 // using POST is a bit more secure than GET | 65 // using POST is a bit more secure than GET |
67 return new Promise((resolve, reject) => { | 66 return new Promise((resolve, reject) => { |
68 // axios will add the application/x-www-form-urlencoded header this way | 67 // axios will add the application/x-www-form-urlencoded header this way |
69 HTTP.post("/login", qs.stringify(user)) | 68 HTTP.post("/login", user) |
70 .then(response => { | 69 .then(response => { |
71 commit("auth_success", response.data); | 70 commit("auth_success", response.data); |
72 resolve(response); | 71 resolve(response); |
73 }) | 72 }) |
74 .catch(error => { | 73 .catch(error => { |