feat: added loginWithCredentials call

This commit is contained in:
Roberto Tonino 2021-05-23 20:34:01 +02:00
parent 856fdbb6b7
commit f659afffd2
3 changed files with 18 additions and 6 deletions

File diff suppressed because one or more lines are too long

View file

@ -802,7 +802,7 @@ import { copyToClipboard } from '@/utils/utils'
import BaseAccordion from '@/components/globals/BaseAccordion.vue'
import TemplateVariablesList from '@components/settings/TemplateVariablesList.vue'
import { fetchData } from '@/utils/api'
import { fetchData, postToServer } from '@/utils/api'
import { getFormItem } from '@/utils/forms'
export default {
@ -993,9 +993,9 @@ export default {
const { username } = fromLoginForm('username')
const { password } = fromLoginForm('password')
// console.log({ username,password })
postToServer('loginWithCredentials', { username, password })
},
appLogin(e) {
appLogin() {
socket.emit('applogin')
},
changeAccount() {

View file

@ -19,3 +19,15 @@ export function sendToServer(key, data) {
fetch(url.href).catch(console.error)
}
export const postToServer = (endpoint, data) => {
const url = new URL(`${window.location.origin}/api/${endpoint}`)
fetch(url, {
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
},
method: 'POST'
}).catch(console.error)
}