Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
love_飞影
Neos
Commits
0676365d
Commit
0676365d
authored
Jul 24, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try sso login
parent
ae3bfdce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
src/ui/Neos.tsx
src/ui/Neos.tsx
+9
-0
src/ui/Sso.tsx
src/ui/Sso.tsx
+57
-0
No files found.
src/ui/Neos.tsx
View file @
0676365d
...
...
@@ -8,6 +8,7 @@ const WaitRoom = React.lazy(() => import("./WaitRoom"));
const
Mora
=
React
.
lazy
(()
=>
import
(
"
./Mora
"
));
const
NeosDuel
=
React
.
lazy
(()
=>
import
(
"
./Duel/Main
"
));
const
Replay
=
React
.
lazy
(()
=>
import
(
"
./Replay
"
));
const
SSO
=
React
.
lazy
(()
=>
import
(
"
./Sso
"
));
export
default
function
()
{
return
(
...
...
@@ -45,6 +46,14 @@ export default function () {
</
Suspense
>
}
/>
<
Route
path=
"/sso/*"
element=
{
<
Suspense
fallback=
{
<
Loading
/>
}
>
<
SSO
/>
</
Suspense
>
}
/>
</
Routes
>
);
}
src/ui/Sso.tsx
0 → 100644
View file @
0676365d
import
React
,
{
useEffect
}
from
"
react
"
;
interface
SSOParams
{
id
:
string
;
username
:
string
;
name
:
string
;
email
:
string
;
return_sso_url
:
string
;
token
:
string
;
}
const
Sso
:
React
.
FC
=
()
=>
{
const
sso
=
new
URL
(
location
.
href
).
searchParams
.
get
(
"
sso
"
);
const
ssoParams
:
SSOParams
|
undefined
=
sso
?
getSSOParams
(
new
URLSearchParams
(
atob
(
sso
)))
:
undefined
;
useEffect
(()
=>
{
if
(
!
sso
)
{
const
ssoUrl
=
getSSOUrl
(
location
.
href
);
window
.
location
.
href
=
ssoUrl
;
}
},
[]);
return
(
<
div
>
<
p
>
username=
{
ssoParams
?.
username
}
</
p
>
<
p
>
name=
{
ssoParams
?.
name
}
</
p
>
<
p
>
email=
{
ssoParams
?.
email
}
</
p
>
</
div
>
);
};
function
getSSOUrl
(
callbackUrl
:
string
):
string
{
let
params
=
new
URLSearchParams
();
params
.
set
(
"
return_sso_url
"
,
callbackUrl
);
const
payload
=
btoa
(
params
.
toString
());
const
url
=
new
URL
(
"
https://accounts.moecube.com
"
);
params
=
url
.
searchParams
;
params
.
set
(
"
sso
"
,
payload
);
return
url
.
toString
();
}
function
getSSOParams
(
searchParams
:
URLSearchParams
):
SSOParams
{
const
sso
=
{};
for
(
const
[
key
,
value
]
of
searchParams
)
{
// @ts-ignore
sso
[
key
]
=
value
;
}
return
sso
as
any
;
}
export
default
Sso
;
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