Browse Source

Clarify license; axios->fetch more

pull/159/head
Dashie der otter 1 year ago
parent
commit
baa5fb9b1c
Signed by: dashie <rhaamo@leloop.org> GPG Key ID: C2D57B325840B755
4 changed files with 37 additions and 19 deletions
  1. +0
    -0
      AGPL-3
  2. +6
    -0
      COPYING
  3. +19
    -8
      front/src/backend/oauth/oauth.js
  4. +12
    -11
      front/src/boot/after_store.js

LICENSE → AGPL-3 View File


+ 6
- 0
COPYING View File

@@ -10,3 +10,9 @@ The following logo assets:

Have been created by Alex Sleepy and are under the same license as the project (AGPL-3) and are made for exclusive usage within this project use.

---

The frontend (front/) contains parts extracted from the Pleroma project
<https://git.pleroma.social/pleroma/pleroma-fe> Frontend and are also
under the AGPL-3.


+ 19
- 8
front/src/backend/oauth/oauth.js View File

@@ -1,5 +1,4 @@
// Snippets extracted from https://git.pleroma.social/pleroma/pleroma-fe/blob/develop/src/services/new_api/oauth.js
import axios from 'axios'
import { reduce } from 'lodash'

const REDIRECT_URI = `${window.location.origin}/oauth-callback`
@@ -19,10 +18,13 @@ export const getOrCreateApp = ({ clientId, clientSecret, instance, commit }) =>
form.append('redirect_uris', REDIRECT_URI)
form.append('scopes', 'read write follow push')

return axios.post(url, form)
.then((data) => data.data)
.then((app) => ({ clientId: app.client_id, clientSecret: app.client_secret }))
.then((app) => commit('setClientData', app) || app)
return window.fetch(url, {
method: 'POST',
body: form
})
.then((data) => data.json())
.then((app) => ({ clientId: app.client_id, clientSecret: app.client_secret }))
.then((app) => commit('setClientData', app) || app)
}

const login = ({ instance, clientId }) => {
@@ -60,7 +62,10 @@ const getTokenWithCredentials = ({ clientId, clientSecret, instance, username, p
form.append('username', username)
form.append('password', password)

return axios.post(url, form).then((data) => data.data)
return window.fetch(url, {
method: 'POST',
body: form
}).then((data) => data.json())
}

const getToken = ({ clientId, clientSecret, instance, code }) => {
@@ -76,7 +81,10 @@ const getToken = ({ clientId, clientSecret, instance, code }) => {
form.append('scope', 'read write follow push')
form.append('redirect_uri', `${window.location.origin}/oauth-callback`)

return axios.post(url, form).then((data) => data.data)
return window.fetch(url, {
method: 'POST',
body: form
}).then((data) => data.json())
}

export const getClientToken = ({ clientId, clientSecret, instance }) => {
@@ -90,7 +98,10 @@ export const getClientToken = ({ clientId, clientSecret, instance }) => {
form.append('scope', 'read write follow push')
form.append('redirect_uri', `${window.location.origin}/oauth-callback`)

return axios.post(url, form).then((data) => data.data)
return window.fetch(url, {
method: 'POST',
body: form
}).then((data) => data.json())
}

const oauth = {


+ 12
- 11
front/src/boot/after_store.js View File

@@ -3,15 +3,15 @@
import Vue from 'vue'
import router from '../router'
import App from '../App.vue'
import axios from 'axios'
import apiService from '../services/api/api.service.js'
import { getOrCreateApp, getClientToken } from '../backend/oauth/oauth.js'

const getNodeInfo = async ({ store }) => {
await axios.get(`${store.state.instance.instanceUrl}/nodeinfo/2.0`)
.then(function (res) {
const data = res.data

try {
const res = await window.fetch(`${store.state.instance.instanceUrl}/nodeinfo/2.0`)
if (res.ok) {
const data = await res.json()
const metadata = data.metadata
store.dispatch('setInstanceOption', { name: 'registrationOpen', value: metadata.openRegistrations })
store.dispatch('setInstanceOption', { name: 'name', value: metadata.nodeName })
@@ -22,11 +22,13 @@ const getNodeInfo = async ({ store }) => {

const frontendVersion = 'FIXME'
store.dispatch('setInstanceOption', { name: 'frontendVersion', value: frontendVersion })
})
.catch(function (e) {
console.warn('Could not load nodeinfo')
console.warn(e)
})
} else {
throw (res)
}
} catch (e) {
console.warn('Could not load nodeinfo')
console.warn(e)
}
}

const checkOAuthToken = async ({ store }) => {
@@ -69,7 +71,6 @@ const setSettings = async ({ store }) => {

const getTOS = async ({ store }) => {
try {
// TODO: axios
const res = await window.fetch('/static/terms-of-service.html')
if (res.ok) {
const html = await res.text()


Loading…
Cancel
Save