feat(auth): rich workspace-aware notification on successful login

Replace the plain "Login successful" toast with a TDesign Notify card
that surfaces the workspace the user just landed in and their role
there, so users immediately see which space they're working in —
especially useful now that login can drop them into a remembered
non-home tenant.

A small shared helper (utils/loginNotify.ts) handles both the password
login path (views/auth/Login.vue) and the OIDC callback path
(App.vue handleGlobalOIDCCallback), so the two flows stay consistent.
Role label goes through the same useRoleLabel composable used by the
rest of the role-aware UI, so locale + future role-name tweaks live in
one place. The membership lookup falls back gracefully (no role line)
when the active tenant isn't in the response's memberships list — e.g.
the auto-setup path that synthesises a single owner row.

The legacy auth.loginSuccess key is left in place; nothing else
references it, so a future cleanup PR can drop it safely.
This commit is contained in:
wizardchen
2026-05-18 20:21:46 +08:00
committed by lyingbug
parent 0cdb922d84
commit 60a579d869
7 changed files with 67 additions and 2 deletions
+4 -1
View File
@@ -372,6 +372,8 @@
import { ref, reactive, nextTick, onMounted, onBeforeUnmount, computed } from 'vue'
import { useRouter } from 'vue-router'
import { MessagePlugin } from 'tdesign-vue-next'
import { useRoleLabel } from '@/composables/useRoleLabel'
import { notifyLoginSuccess } from '@/utils/loginNotify'
import { Swiper, SwiperSlide } from 'swiper/vue'
import { Autoplay, EffectFade, Pagination } from 'swiper/modules'
import 'swiper/css'
@@ -389,6 +391,7 @@ import screenshot4 from '@/assets/img/screenshot-4.svg'
const router = useRouter()
const authStore = useAuthStore()
const { t, locale } = useI18n()
const { formatRole } = useRoleLabel()
// Swiper modules
const modules = [Autoplay, EffectFade, Pagination]
@@ -662,8 +665,8 @@ const handleLogin = async () => {
})
if (response.success) {
MessagePlugin.success(t('auth.loginSuccess'))
await persistLoginResponse(response)
notifyLoginSuccess(response, t, formatRole)
} else {
MessagePlugin.error(response.message || t('auth.loginError'))
}