-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This feature serves two purposes: - sets a variable on both frontend and backend indicating that we are in single-user mode. this is the concept we'll use to switch between public SaaS and private single-user - sets a single User ID that is sent to all ~users~ This makes sure that anyone connecting is on the same session, sees the same projects. Even though the cookie might expire, re-requesting one gets the same User ID. On the backend, if SINGLE_USER_ID is set, it is checked for existence on start or created if not. In the frontend, homepage checks whether it is expecting a single user mode (ENV) and if yes, fetches the User and Projects from backend before redirecting to /collections
- Loading branch information
Showing
10 changed files
with
109 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<div class="d-flex flex-column vh-100"> | ||
<div class="flex-shrink-1"> | ||
<p>Retrieving single user & projects…</p> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { type Project } from '@/constants' | ||
import type { User } from '@/constants' | ||
import { useAppStore, useProjectStore } from '@/stores/stores' | ||
import { createNewProject } from '@/utils' | ||
import router from '@/router' | ||
const storeProject = useProjectStore() | ||
const storeApp = useAppStore() | ||
async function restrieveUser(): Promise<User | null> { | ||
var user: User | null = null | ||
try { | ||
const createUserRespone = await storeApp.axiosInstance.post<User>('/users') | ||
user = createUserRespone.data | ||
} catch (error: any) { | ||
console.log('Unable to create a new user.', error) | ||
storeApp.alertsError('Unable to create a new user.') | ||
} | ||
return user | ||
} | ||
async function retrieveProjects(): Promise<Project[]> { | ||
var projects: Project[] = [] | ||
try { | ||
const response = await storeApp.axiosInstance.get<Project[]>('/projects') | ||
console.log(response.data) | ||
projects = response.data | ||
} catch (error: unknown) { | ||
console.log('Unable to retrieve projects info', error) | ||
storeApp.alertsError('Unable to retrieve projects info') | ||
} | ||
if (projects.length == 0) { | ||
let project: Project | null = await createNewProject('First Project') | ||
if (project !== null) { | ||
projects.push(project) | ||
} | ||
} | ||
return projects | ||
} | ||
await restrieveUser() | ||
const projects = await retrieveProjects() | ||
storeProject.setProjects(projects) | ||
if (projects.length) { | ||
storeProject.setLastProjectId(projects[projects.length - 1].id) | ||
} | ||
router.push('/collections') | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters