stash
This commit is contained in:
parent
02e41214d2
commit
7e8f984ee2
7 changed files with 15 additions and 12 deletions
File diff suppressed because one or more lines are too long
|
|
@ -48,6 +48,7 @@
|
|||
<script>
|
||||
import {mapGetters, mapMutations} from 'vuex';
|
||||
import * as BIcons from "bootstrap-icons-vue";
|
||||
import moment from 'moment';
|
||||
|
||||
export default {
|
||||
name: 'Notifications',
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class ServerSet {
|
|||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...auth.buildAuthHeader(url)
|
||||
...auth.buildAuthHeader(url, data)
|
||||
},
|
||||
credentials: 'omit',
|
||||
body: JSON.stringify(data)
|
||||
|
|
@ -55,7 +55,7 @@ class ServerSet {
|
|||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...auth.buildAuthHeader(url)
|
||||
...auth.buildAuthHeader(url, data)
|
||||
},
|
||||
credentials: 'omit',
|
||||
body: JSON.stringify(data)
|
||||
|
|
@ -132,7 +132,7 @@ class ServerSet {
|
|||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...auth.buildAuthHeader(url)
|
||||
...auth.buildAuthHeader(url, data)
|
||||
},
|
||||
credentials: 'omit',
|
||||
body: JSON.stringify(data)
|
||||
|
|
@ -167,6 +167,7 @@ function createSignAuth(username, signKey) {
|
|||
return new authMethod(({signKey, username}, {url, data}) => {
|
||||
const json = JSON.stringify(data)
|
||||
const signature = nacl.crypto_sign_detached(nacl.encode_utf8(url + (data ? json : "")), signKey)
|
||||
console.log('sign', nacl.to_hex(signature), url, json)
|
||||
return {'Authorization': 'Signature ' + username + ':' + nacl.to_hex(signature)}
|
||||
}, context)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { BootstrapIconsPlugin } from 'bootstrap-icons-vue';
|
|||
import App from './App.vue'
|
||||
|
||||
import './assets/css/toolshed.css'
|
||||
import './assets/js/app.js'
|
||||
|
||||
import router from './router'
|
||||
import store from './store';
|
||||
|
|
|
|||
|
|
@ -175,15 +175,16 @@ export default createStore({
|
|||
const servers = await dispatch('getAllFriendsServers')
|
||||
return await servers.get(getters.signAuth, '/api/inventory/search/?q=' + query)
|
||||
},
|
||||
async createInventoryItem({state, dispatch, getters}, {item}) {
|
||||
async createInventoryItem({state, dispatch, getters}, item) {
|
||||
const servers = await dispatch('getHomeServers')
|
||||
return await servers.post(getters.signAuth, '/api/inventory_items/', item)
|
||||
const data = {...item, owned_amount: 1, availability_policy: 'friends', category: 'other'}
|
||||
return await servers.post(getters.signAuth, '/api/inventory_items/', data)
|
||||
},
|
||||
async updateInventoryItem({state, dispatch, getters}, {item}) {
|
||||
async updateInventoryItem({state, dispatch, getters}, item) {
|
||||
const servers = await dispatch('getHomeServers')
|
||||
return await servers.patch(getters.signAuth, '/api/inventory_items/' + item.id + '/', item)
|
||||
},
|
||||
async deleteInventoryItem({state, dispatch, getters}, {item}) {
|
||||
async deleteInventoryItem({state, dispatch, getters}, item) {
|
||||
const servers = await dispatch('getHomeServers')
|
||||
return await servers.delete(getters.signAuth, '/api/inventory_items/' + item.id + '/')
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue