Skip to content

Commit

Permalink
feat: sso compatibility mode (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsHenry35 committed Sep 22, 2023
1 parent 57df6c4 commit 6eb8ffd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/lang/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"OIDC": "OIDC"
},
"sso_organization_name": "Sso organization name",
"sso_compatibility_mode": "Sso compatibility mode (Use redirect instead of popup to support certain services)",
"text_types": "Text types",
"token": "Token",
"version": "Version",
Expand Down
12 changes: 11 additions & 1 deletion src/pages/login/SSOLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import { onCleanup } from "solid-js"
const SSOLogin = () => {
const ssoSignEnabled = getSettingBool("sso_login_enabled")
const loginPlatform = getSetting("sso_login_platform")
const usecompatibility = getSettingBool("sso_compatibility_mode")
const { searchParams, to } = useRouter()
const token = searchParams["token"]
if (token != undefined && token != "") {
changeToken(token)
to(decodeURIComponent(searchParams.redirect || base_path || "/"), true)
}
function messageEvent(event: MessageEvent) {
const data = event.data
if (data.token) {
Expand All @@ -25,7 +31,11 @@ const SSOLogin = () => {
if (ssoSignEnabled) {
const login = () => {
const url = r.getUri() + "/auth/sso?method=sso_get_token"
const popup = window.open(url, "authPopup", "width=500,height=600")
if (usecompatibility) {
window.location.href = url
return
}
window.open(url, "authPopup", "width=500,height=600")
}
let icon
switch (loginPlatform) {
Expand Down
18 changes: 12 additions & 6 deletions src/pages/manage/users/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ const PermissionBadge = (props: { can: boolean; children: JSXElement }) => {
const Profile = () => {
const t = useT()
useManageTitle("manage.sidemenu.profile")
const { to } = useRouter()
const { searchParams, to } = useRouter()
const [username, setUsername] = createSignal(me().username)
const [password, setPassword] = createSignal("")
const [confirmPassword, setConfirmPassword] = createSignal("")
const usecompatibility = getSettingBool("sso_compatibility_mode")
const [loading, save] = useFetch(
(ssoID?: boolean): PEmptyResp =>
r.post("/me/update", {
Expand Down Expand Up @@ -101,6 +102,11 @@ const Profile = () => {
}
})
}
const ssoID = searchParams["sso_id"]
if (ssoID) {
setMe({ ...me(), sso_id: ssoID })
saveMe(true)
}
function messageEvent(event: MessageEvent) {
const data = event.data
if (data.sso_id) {
Expand Down Expand Up @@ -228,11 +234,11 @@ const Profile = () => {
<Button
onClick={() => {
const url = r.getUri() + "/auth/sso?method=get_sso_id"
const popup = window.open(
url,
"authPopup",
"width=500,height=600",
)
if (usecompatibility) {
window.location.href = url
return
}
window.open(url, "authPopup", "width=500,height=600")
}}
>
{t("users.connect_sso")}
Expand Down

0 comments on commit 6eb8ffd

Please sign in to comment.