Added Load/Save API for page bodies
This commit is contained in:
parent
98fc0ef0f8
commit
29058b37d0
16 changed files with 910 additions and 35 deletions
89
motorradig/public/js/app.js
vendored
89
motorradig/public/js/app.js
vendored
|
|
@ -1990,6 +1990,11 @@ __webpack_require__.r(__webpack_exports__);
|
|||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
/* harmony default export */ __webpack_exports__["default"] = ({
|
||||
data: function data() {
|
||||
return {
|
||||
|
|
@ -2001,17 +2006,18 @@ __webpack_require__.r(__webpack_exports__);
|
|||
logout: function logout() {
|
||||
var _this = this;
|
||||
|
||||
console.log("logging out with token " + this.$store.state.user.token); // Empty brackets are an empty object usually containing form data
|
||||
console.log("logging out with token " + this.$store.state.user_token); // Empty brackets are an empty object usually containing form data
|
||||
|
||||
axios.post('http://localhost:8000/api/v1/auth/logout', {}, {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + this.$store.state.user.token
|
||||
'Authorization': 'Bearer ' + this.$store.state.user_token
|
||||
}
|
||||
}).then(function (res) {
|
||||
console.log("Logout successful");
|
||||
_this.$store.state.user.token = null;
|
||||
_this.$store.state.user_token = null;
|
||||
|
||||
_this.$router.go(); //Reload page with updated access-based display
|
||||
|
||||
_this.$router.push('/');
|
||||
})["catch"](function (error) {
|
||||
console.log("Logout unsuccessful.");
|
||||
console.log(error);
|
||||
|
|
@ -2019,6 +2025,31 @@ __webpack_require__.r(__webpack_exports__);
|
|||
},
|
||||
editPage: function editPage() {
|
||||
this.$router.push('/edit_page');
|
||||
},
|
||||
loadPage: function loadPage() {
|
||||
axios.post('http://localhost:8000/api/v1/auth/load_page', {
|
||||
page: 'testpage'
|
||||
}, {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + this.$store.state.user_token
|
||||
}
|
||||
}).then(function (res) {
|
||||
console.log("savePage: Loading Testpage");
|
||||
console.log("Body:");
|
||||
console.log(res.data.body);
|
||||
});
|
||||
},
|
||||
savePage: function savePage() {
|
||||
axios.post('http://localhost:8000/api/v1/auth/save_page', {
|
||||
page: 'testpage',
|
||||
body: 'testbody'
|
||||
}, {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + this.$store.state.user_token
|
||||
}
|
||||
}).then(function (res) {
|
||||
console.log("savePage: Wrote Testpage");
|
||||
});
|
||||
}
|
||||
},
|
||||
created: function created() {
|
||||
|
|
@ -2117,10 +2148,13 @@ __webpack_require__.r(__webpack_exports__);
|
|||
}).then(function (res) {
|
||||
console.log("Login successful. Token=" + res.headers.authorization);
|
||||
_this.$store.state.user_token = res.headers.authorization;
|
||||
_this.$store.state.user = res.data.user; //console.log("Storing user data:");
|
||||
//console.log(res.data.user);
|
||||
//console.log("Test extraction:");
|
||||
//console.log(this.$store.state.user.role);
|
||||
_this.$store.state.user = res.data.user;
|
||||
console.log("Storing user data:");
|
||||
console.log(res.data.user);
|
||||
console.log("Test extraction:");
|
||||
console.log(_this.$store.state.user.role);
|
||||
console.log(_this.$store.state.user.token);
|
||||
console.log(_this.$store.state.user_token);
|
||||
|
||||
_this.$router.push('/');
|
||||
})["catch"](function (error) {
|
||||
|
|
@ -31196,6 +31230,45 @@ var render = function() {
|
|||
[_vm._v("Impressum")]
|
||||
),
|
||||
_vm._v(" "),
|
||||
_c(
|
||||
"button",
|
||||
{
|
||||
staticClass: "button",
|
||||
on: {
|
||||
click: function($event) {
|
||||
return _vm.savePage()
|
||||
}
|
||||
}
|
||||
},
|
||||
[_vm._v("Save Page")]
|
||||
),
|
||||
_vm._v(" "),
|
||||
_c(
|
||||
"button",
|
||||
{
|
||||
staticClass: "button",
|
||||
on: {
|
||||
click: function($event) {
|
||||
return _vm.loadPage()
|
||||
}
|
||||
}
|
||||
},
|
||||
[_vm._v("Load Page")]
|
||||
),
|
||||
_vm._v(" "),
|
||||
_c(
|
||||
"button",
|
||||
{
|
||||
staticClass: "button",
|
||||
on: {
|
||||
click: function($event) {
|
||||
return _vm.logout()
|
||||
}
|
||||
}
|
||||
},
|
||||
[_vm._v("Logout")]
|
||||
),
|
||||
_vm._v(" "),
|
||||
_c(
|
||||
"router-link",
|
||||
{ staticClass: "button", attrs: { to: { name: "Login" } } },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue