feat: 增加首次进入系统强制修改用户密码功能(#3)

This commit is contained in:
shaohuzhang1 2024-04-18 18:34:15 +08:00 committed by GitHub
parent 553af5f783
commit 39f573610d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 2 deletions

View File

@ -418,7 +418,8 @@ class UserProfile(ApiMixin):
permission_list = get_user_dynamics_permission(str(user.id))
permission_list += [p.value for p in get_permission_list_by_role(RoleConstants[user.role])]
return {'id': user.id, 'username': user.username, 'email': user.email, 'role': user.role,
'permissions': [str(p) for p in permission_list]}
'permissions': [str(p) for p in permission_list],
'is_edit_password': user.password == 'd880e722c47a34d8e9fce789fc62389d' if user.role == 'ADMIN' else False}
@staticmethod
def get_response_body_api():

View File

@ -19,6 +19,10 @@ interface User {
*
*/
permissions: Array<string>
/**
*
*/
is_edit_password?: boolean
}
interface LoginRequest {

View File

@ -30,16 +30,19 @@
</el-dropdown>
<ResetPassword ref="resetPasswordRef"></ResetPassword>
<AboutDialog ref="AboutDialogRef"></AboutDialog>
<UserPwdDialog ref="UserPwdDialogRef" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ref, onMounted } from 'vue'
import useStore from '@/stores'
import { useRouter } from 'vue-router'
import ResetPassword from './ResetPassword.vue'
import AboutDialog from './AboutDialog.vue'
import UserPwdDialog from '@/views/user-manage/component/UserPwdDialog.vue'
const { user } = useStore()
const router = useRouter()
const UserPwdDialogRef = ref()
const AboutDialogRef = ref()
const resetPasswordRef = ref<InstanceType<typeof ResetPassword>>()
@ -56,6 +59,12 @@ const logout = () => {
router.push({ name: 'login' })
})
}
onMounted(() => {
if (user.userInfo?.is_edit_password) {
UserPwdDialogRef.value.open(user.userInfo)
}
})
</script>
<style lang="scss" scoped>
.avatar-dropdown {