feat: add useradmin role -运营管理员权限,支持管理用户/订单/风控等
This commit is contained in:
@@ -13,7 +13,8 @@ const (
|
|||||||
// Role constants
|
// Role constants
|
||||||
const (
|
const (
|
||||||
RoleAdmin = "admin"
|
RoleAdmin = "admin"
|
||||||
RoleUser = "user"
|
RoleUser = "user"
|
||||||
|
RoleUserAdmin = "useradmin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Platform constants
|
// Platform constants
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func AdminOnly() gin.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否为管理员
|
// 检查是否为超级管理员(admin)
|
||||||
if role != service.RoleAdmin {
|
if role != service.RoleAdmin {
|
||||||
AbortWithError(c, 403, "FORBIDDEN", "Admin access required")
|
AbortWithError(c, 403, "FORBIDDEN", "Admin access required")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ const (
|
|||||||
|
|
||||||
// Role constants
|
// Role constants
|
||||||
const (
|
const (
|
||||||
RoleAdmin = domain.RoleAdmin
|
RoleAdmin = domain.RoleAdmin
|
||||||
RoleUser = domain.RoleUser
|
RoleUser = domain.RoleUser
|
||||||
|
RoleUserAdmin = domain.RoleUserAdmin
|
||||||
)
|
)
|
||||||
|
|
||||||
// Affiliate rebate settings
|
// Affiliate rebate settings
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ type User struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) IsAdmin() bool {
|
func (u *User) IsAdmin() bool {
|
||||||
return u.Role == RoleAdmin
|
return u.Role == RoleAdmin || u.Role == RoleUserAdmin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) IsActive() bool {
|
func (u *User) IsActive() bool {
|
||||||
|
|||||||
@@ -765,8 +765,8 @@ router.beforeEach((to, _from, next) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check admin requirement
|
// Check admin requirement (requires admin role, not useradmin)
|
||||||
if (requiresAdmin && !authStore.isAdmin) {
|
if (requiresAdmin && !authStore.isSuperAdmin) {
|
||||||
// User is authenticated but not admin, redirect to user dashboard
|
// User is authenticated but not admin, redirect to user dashboard
|
||||||
next('/dashboard')
|
next('/dashboard')
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const isAdmin = computed(() => {
|
const isAdmin = computed(() => {
|
||||||
|
return user.value?.role === 'admin' || user.value?.role === 'useradmin'
|
||||||
|
})
|
||||||
|
|
||||||
|
const isSuperAdmin = computed(() => {
|
||||||
return user.value?.role === 'admin'
|
return user.value?.role === 'admin'
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -476,6 +480,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
// Computed
|
// Computed
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
|
isSuperAdmin,
|
||||||
isSimpleMode,
|
isSimpleMode,
|
||||||
hasPendingAuthSession,
|
hasPendingAuthSession,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user