generated from codersforcauses/django-vue-template
-
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.
Issue 14 create user pinia store (#38)
* user.ts v1 * fixed file v1 * Comments Add * Test included * Fixed to fit with CI/CD process * Properties Update & Poetry Fix * Test files Update * Repair user.ts * Emergency Update * Emergency Update v2 * Comments Update * Remove Test
- Loading branch information
Showing
4 changed files
with
136 additions
and
54 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,27 @@ | ||
import { defineStore } from 'pinia' | ||
import { useStorage } from '@vueuse/core' | ||
import { computed } from 'vue' | ||
import type { User } from '@/types/user' | ||
|
||
export const useUserStore = defineStore('user', () => { | ||
const userData = useStorage<User | null>('userData', null) | ||
const accessToken = useStorage<string | null>('accessToken', null) | ||
const refreshToken = useStorage<string | null>('refreshToken', null) | ||
|
||
const isLoggedIn = computed(() => userData.value !== null) | ||
|
||
//Logout Status | ||
const logout = () => { | ||
userData.value = null | ||
accessToken.value = null | ||
refreshToken.value = null | ||
} | ||
|
||
return { | ||
userData, | ||
isLoggedIn, | ||
accessToken, | ||
refreshToken, | ||
logout, | ||
} | ||
}) |
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,11 @@ | ||
export interface User { | ||
userId: number | ||
userName: string | ||
firstName: string | ||
lastName: string | ||
bio: string | ||
totalPoints: number | ||
email: string | ||
visibility: 0 | 1 | 2 | ||
avatar: 0 | 1 | 2 | 3 | 4 | 5 | ||
} |