Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
472afce9
Commit
472afce9
authored
Nov 25, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix current user store
parent
a12844f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
0 deletions
+9
-0
AuthCallback.tsx
web/src/pages/AuthCallback.tsx
+3
-0
SignIn.tsx
web/src/pages/SignIn.tsx
+3
-0
SignUp.tsx
web/src/pages/SignUp.tsx
+3
-0
No files found.
web/src/pages/AuthCallback.tsx
View file @
472afce9
...
...
@@ -7,6 +7,7 @@ import * as api from "@/helpers/api";
import
{
absolutifyLink
}
from
"@/helpers/utils"
;
import
useNavigateTo
from
"@/hooks/useNavigateTo"
;
import
{
useUserStore
}
from
"@/store/module"
;
import
{
useUserV1Store
}
from
"@/store/v1"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
interface
State
{
...
...
@@ -19,6 +20,7 @@ const AuthCallback = () => {
const
navigateTo
=
useNavigateTo
();
const
[
searchParams
]
=
useSearchParams
();
const
userStore
=
useUserStore
();
const
userV1Store
=
useUserV1Store
();
const
[
state
,
setState
]
=
useState
<
State
>
({
loading
:
true
,
errorMessage
:
""
,
...
...
@@ -42,6 +44,7 @@ const AuthCallback = () => {
if
(
user
)
{
userStore
.
setCurrentUser
(
user
);
await
userStore
.
fetchCurrentUser
();
await
userV1Store
.
getOrFetchUserByUsername
(
user
.
username
);
navigateTo
(
"/"
);
}
else
{
toast
.
error
(
t
(
"message.login-failed"
));
...
...
web/src/pages/SignIn.tsx
View file @
472afce9
...
...
@@ -9,6 +9,7 @@ import { absolutifyLink } from "@/helpers/utils";
import
useLoading
from
"@/hooks/useLoading"
;
import
useNavigateTo
from
"@/hooks/useNavigateTo"
;
import
{
useGlobalStore
,
useUserStore
}
from
"@/store/module"
;
import
{
useUserV1Store
}
from
"@/store/v1"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
const
SignIn
=
()
=>
{
...
...
@@ -16,6 +17,7 @@ const SignIn = () => {
const
navigateTo
=
useNavigateTo
();
const
globalStore
=
useGlobalStore
();
const
userStore
=
useUserStore
();
const
userV1Store
=
useUserV1Store
();
const
actionBtnLoadingState
=
useLoading
(
false
);
const
{
appearance
,
locale
,
systemStatus
}
=
globalStore
.
state
;
const
mode
=
systemStatus
.
profile
.
mode
;
...
...
@@ -78,6 +80,7 @@ const SignIn = () => {
if
(
user
)
{
userStore
.
setCurrentUser
(
user
);
await
userStore
.
fetchCurrentUser
();
await
userV1Store
.
getOrFetchUserByUsername
(
user
.
username
);
navigateTo
(
"/"
);
}
else
{
toast
.
error
(
t
(
"message.login-failed"
));
...
...
web/src/pages/SignUp.tsx
View file @
472afce9
...
...
@@ -8,6 +8,7 @@ import * as api from "@/helpers/api";
import
useLoading
from
"@/hooks/useLoading"
;
import
useNavigateTo
from
"@/hooks/useNavigateTo"
;
import
{
useGlobalStore
,
useUserStore
}
from
"@/store/module"
;
import
{
useUserV1Store
}
from
"@/store/v1"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
const
SignUp
=
()
=>
{
...
...
@@ -15,6 +16,7 @@ const SignUp = () => {
const
navigateTo
=
useNavigateTo
();
const
globalStore
=
useGlobalStore
();
const
userStore
=
useUserStore
();
const
userV1Store
=
useUserV1Store
();
const
actionBtnLoadingState
=
useLoading
(
false
);
const
{
appearance
,
locale
,
systemStatus
}
=
globalStore
.
state
;
const
[
username
,
setUsername
]
=
useState
(
""
);
...
...
@@ -58,6 +60,7 @@ const SignUp = () => {
if
(
user
)
{
userStore
.
setCurrentUser
(
user
);
await
userStore
.
fetchCurrentUser
();
await
userV1Store
.
getOrFetchUserByUsername
(
user
.
username
);
navigateTo
(
"/"
);
}
else
{
toast
.
error
(
t
(
"message.signup-failed"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment