♻️ (authentication)

This commit is contained in:
Julien Calixte
2021-05-27 13:24:55 +02:00
parent 98e329c93f
commit 5f272a44bb
2 changed files with 6 additions and 2 deletions

View File

@@ -31,7 +31,7 @@ export default defineComponent({
saveCredentials(body) saveCredentials(body)
} }
router.push({ name: 'Home' }) router.replace({ name: 'Home' })
} }
}) })

View File

@@ -5,6 +5,7 @@ import {
getMainReadme, getMainReadme,
getUserSettingsContent getUserSettingsContent
} from '@/modules/repo/services/repo' } from '@/modules/repo/services/repo'
import { refreshToken } from '@/modules/user/service/signIn'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
interface State { interface State {
@@ -13,6 +14,7 @@ interface State {
files: RepoFile[] files: RepoFile[]
readme?: string | null readme?: string | null
userSettings?: UserSettings | null userSettings?: UserSettings | null
needToLogin: boolean
} }
export const useUserRepoStore = defineStore({ export const useUserRepoStore = defineStore({
@@ -22,12 +24,14 @@ export const useUserRepoStore = defineStore({
repo: '', repo: '',
files: [], files: [],
readme: undefined, readme: undefined,
userSettings: undefined userSettings: undefined,
needToLogin: false
}), }),
actions: { actions: {
async setUserRepo(newUser: string, newRepo: string) { async setUserRepo(newUser: string, newRepo: string) {
this.user = newUser this.user = newUser
this.repo = newRepo this.repo = newRepo
await refreshToken()
const [readme, files] = await Promise.all([ const [readme, files] = await Promise.all([
getMainReadme(newUser, newRepo), getMainReadme(newUser, newRepo),
getFiles(newUser, newRepo) getFiles(newUser, newRepo)