2019-04-04 15:35:08 +02:00
|
|
|
import { Module, ActionTree } from 'vuex'
|
2019-04-14 16:11:24 +02:00
|
|
|
import { RootState } from '@/store'
|
2019-12-04 15:03:34 +01:00
|
|
|
import { MyWindow } from '~/src/types/global'
|
|
|
|
|
2020-04-11 11:22:49 +02:00
|
|
|
const win = (window as any) as MyWindow
|
2019-04-04 15:35:08 +02:00
|
|
|
|
2019-06-06 16:44:50 +02:00
|
|
|
export type AuthorizeState = {}
|
2019-04-04 15:35:08 +02:00
|
|
|
|
|
|
|
const state = (): AuthorizeState => ({})
|
|
|
|
|
2019-04-14 16:11:24 +02:00
|
|
|
const actions: ActionTree<AuthorizeState, RootState> = {
|
2020-11-28 14:54:43 +01:00
|
|
|
submit: async (_, request: { code: string | null; sns: 'mastodon' | 'pleroma' | 'misskey' }): Promise<string> => {
|
|
|
|
let req = {
|
|
|
|
sns: request.sns
|
|
|
|
}
|
|
|
|
if (request.code) {
|
|
|
|
req = Object.assign(req, {
|
|
|
|
code: request.code.trim()
|
2019-04-04 15:35:08 +02:00
|
|
|
})
|
2020-11-28 14:54:43 +01:00
|
|
|
}
|
|
|
|
const id = await win.ipcRenderer.invoke('get-access-token', req)
|
|
|
|
return id
|
2019-04-04 15:35:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-14 16:11:24 +02:00
|
|
|
const Authorize: Module<AuthorizeState, RootState> = {
|
2019-04-04 15:35:08 +02:00
|
|
|
namespaced: true,
|
|
|
|
state: state,
|
|
|
|
mutations: {},
|
|
|
|
actions: actions
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Authorize
|