casdoor对接企业微信,casdoor端口地址改为8870

This commit is contained in:
sophie committed 2026-05-09 14:02:18 +08:00
1 parent 7eed474125
commit c21a831796
14 files changed
+375 -28

No files matched your search

+37 -3
View File
@@ -504,9 +504,40 @@ const tryCasdoorCallbackLogin = async () => {
const handleWecomLogin = async () => {
if (!config.auth?.wecom?.enabled) return;
const wecomCfg = config.auth.wecom as { loginViaCasdoor?: boolean; callbackPath?: string; authorizeApi?: string };
const viaCasdoor = Boolean(wecomCfg?.loginViaCasdoor);
try {
const redirectUri = `${window.location.origin}${config.auth.wecom.callbackPath || '/workspace'}`;
const api = config.auth.wecom.authorizeApi || '/api/user/wecom/authorize-url';
if (viaCasdoor) {
if (!config.auth?.casdoor?.enabled) {
showMessageDialog('error', t('login.wecomStartFailed'));
return;
}
const callbackPath = config.auth.casdoor.callbackPath || '/casdoor-callback';
const redirectUri = `${window.location.origin}${callbackPath}`;
const api = config.auth.casdoor.authorizeApi || '/api/user/casdoor/authorize-url';
const qs = new URLSearchParams({
redirect_uri: redirectUri,
default_provider: 'wecom',
});
const hint = (config.auth.casdoor as { wecomProviderHint?: string }).wecomProviderHint?.trim();
if (hint) {
qs.set('provider_hint', hint);
}
const res = await fetch(`${api}?${qs.toString()}`);
const data = await res.json();
if (!res.ok || !data.url) {
showMessageDialog('error', data.error || t('login.wecomStartFailed'));
return;
}
if (data.state) {
sessionStorage.setItem('hxops_casdoor_state', data.state);
}
window.location.href = data.url;
return;
}
const redirectUri = `${window.location.origin}${wecomCfg.callbackPath || '/workspace'}`;
const api = wecomCfg.authorizeApi || '/api/user/wecom/authorize-url';
const res = await fetch(`${api}?redirect_uri=${encodeURIComponent(redirectUri)}`);
const data = await res.json();
if (!res.ok || !data.url) {
@@ -604,6 +635,9 @@ const submitWecomCompleteBind = async () => {
const tryWecomCallbackLogin = async () => {
if (!config.auth?.wecom?.enabled) return false;
if ((config.auth.wecom as { loginViaCasdoor?: boolean }).loginViaCasdoor) {
return false;
}
const wecomPath = config.auth.wecom.callbackPath || '/workspace';
if (window.location.pathname !== wecomPath) return false;
@@ -1131,7 +1165,7 @@ onBeforeUnmount(() => {
</button>
<button
v-if="config.auth?.wecom?.enabled"
v-if="config.auth?.wecom?.enabled && (!config.auth?.wecom?.loginViaCasdoor || config.auth?.casdoor?.enabled)"
@click="handleWecomLogin"
:disabled="isWecomLoggingIn"
class="btn-secondary w-full py-3 text-base mt-3 disabled:opacity-60 disabled:cursor-not-allowed"