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
58ae3217
Commit
58ae3217
authored
Apr 09, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update auth callback messages
parent
6028838f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
35 deletions
+46
-35
CreateIdentityProviderDialog.tsx
web/src/components/CreateIdentityProviderDialog.tsx
+1
-1
TagsSection.tsx
web/src/components/HomeSidebar/TagsSection.tsx
+3
-2
AuthCallback.tsx
web/src/pages/AuthCallback.tsx
+42
-32
No files found.
web/src/components/CreateIdentityProviderDialog.tsx
View file @
58ae3217
...
...
@@ -236,7 +236,7 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
return
(
<>
<
div
className=
"dialog-header-container"
>
<
p
className=
"title-text ml-auto"
>
{
t
(
isCreating
?
"setting.sso-section.create-sso"
:
"setting.sso-section.update-sso"
)
}
</
p
>
<
p
>
{
t
(
isCreating
?
"setting.sso-section.create-sso"
:
"setting.sso-section.update-sso"
)
}
</
p
>
<
IconButton
size=
"sm"
onClick=
{
handleCloseBtnClick
}
>
<
Icon
.
X
className=
"w-5 h-auto"
/>
</
IconButton
>
...
...
web/src/components/HomeSidebar/TagsSection.tsx
View file @
58ae3217
...
...
@@ -90,8 +90,9 @@ const TagsSection = () => {
))
}
</
div
>
)
:
(
<
div
>
<
p
className=
"text-sm leading-snug italic text-gray-400 dark:text-gray-500"
>
<
div
className=
"p-2 border rounded-md flex flex-row justify-start items-start gap-1 text-gray-400 dark:text-gray-500"
>
<
Icon
.
ThumbsUp
/>
<
p
className=
"mt-0.5 text-sm leading-snug italic"
>
You can create tags by inputting
<
code
>
`#tag`
</
code
>
.
</
p
>
</
div
>
...
...
web/src/pages/AuthCallback.tsx
View file @
58ae3217
import
{
last
}
from
"lodash-es"
;
import
{
ClientError
}
from
"nice-grpc-web"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
useSearchParams
}
from
"react-router-dom"
;
...
...
@@ -28,46 +29,55 @@ const AuthCallback = () => {
const
code
=
searchParams
.
get
(
"code"
);
const
state
=
searchParams
.
get
(
"state"
);
if
(
code
&&
state
)
{
const
redirectUri
=
absolutifyLink
(
"/auth/callback"
);
const
identityProviderId
=
Number
(
last
(
state
.
split
(
"-"
)));
if
(
identityProviderId
)
{
authServiceClient
.
signInWithSSO
({
idpId
:
identityProviderId
,
code
,
redirectUri
,
})
.
then
(
async
({
user
})
=>
{
setState
({
loading
:
false
,
errorMessage
:
""
,
});
if
(
user
)
{
await
userStore
.
fetchCurrentUser
();
navigateTo
(
"/"
);
}
else
{
toast
.
error
(
t
(
"message.login-failed"
));
}
})
.
catch
((
error
:
any
)
=>
{
console
.
error
(
error
);
setState
({
loading
:
false
,
errorMessage
:
JSON
.
stringify
(
error
.
response
.
data
,
null
,
2
),
});
});
}
}
else
{
if
(
!
code
||
!
state
)
{
setState
({
loading
:
false
,
errorMessage
:
"Failed to authorize. Invalid state passed to the auth callback."
,
});
return
;
}
const
identityProviderId
=
Number
(
last
(
state
.
split
(
"-"
)));
if
(
!
identityProviderId
)
{
setState
({
loading
:
false
,
errorMessage
:
"No identity provider ID found in the state parameter."
,
});
return
;
}
const
redirectUri
=
absolutifyLink
(
"/auth/callback"
);
(
async
()
=>
{
try
{
const
{
user
}
=
await
authServiceClient
.
signInWithSSO
({
idpId
:
identityProviderId
,
code
,
redirectUri
,
});
setState
({
loading
:
false
,
errorMessage
:
""
,
});
if
(
!
user
)
{
toast
.
error
(
t
(
"message.login-failed"
));
return
;
}
await
userStore
.
fetchCurrentUser
();
navigateTo
(
"/"
);
}
catch
(
error
:
any
)
{
console
.
error
(
error
);
setState
({
loading
:
false
,
errorMessage
:
(
error
as
ClientError
).
details
,
});
}
})();
},
[
searchParams
]);
return
(
<
div
className=
"p-4 w-full h-full flex justify-center items-center"
>
<
div
className=
"p-4
py-24
w-full h-full flex justify-center items-center"
>
{
state
.
loading
?
(
<
Icon
.
Loader
className=
"animate-spin dark:text-gray-200"
/>
)
:
(
...
...
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