Commit c7f3c9d9 authored by NGPixel's avatar NGPixel Committed by Nicolas Giard

feat: user profile fetch info + groups

parent 8ea699ac
......@@ -180,11 +180,10 @@
//- v-list-item-content
//- v-list-item-title {{$t('common:header.myWiki')}}
//- v-list-item-subtitle.overline Coming soon
//- v-list-item(href='/p', disabled)
//- v-list-item-action: v-icon(color='blue') mdi-face-profile
//- v-list-item-content
//- v-list-item-title {{$t('common:header.profile')}}
//- v-list-item-subtitle.overline Coming soon
v-list-item(href='/p')
v-list-item-action: v-icon(color='blue-grey') mdi-face-profile
v-list-item-content
v-list-item-title(:class='$vuetify.theme.dark ? `blue-grey--text text--lighten-3` : `blue-grey--text`') {{$t('common:header.profile')}}
v-list-item(href='/a', v-if='isAuthenticated && isAdmin')
v-list-item-action.btn-animate-rotate: v-icon(:color='$vuetify.theme.dark ? `blue-grey lighten-3` : `blue-grey`') mdi-cog
v-list-item-title(:class='$vuetify.theme.dark ? `blue-grey--text text--lighten-3` : `blue-grey--text`') {{$t('common:header.admin')}}
......
......@@ -4,14 +4,14 @@
v-navigation-drawer.pb-0(v-model='profileDrawerShown', app, fixed, clipped, left, permanent)
v-list(dense, nav)
v-list-item(to='/profile')
v-list-item-action: v-icon mdi-account-badge
v-list-item-action: v-icon mdi-face-profile
v-list-item-content
v-list-item-title Profile
v-list-item(to='/preferences', disabled)
v-list-item-action: v-icon(color='grey lighten-1') mdi-settings-outline
v-list-item-content
v-list-item-title Preferences
v-list-item-subtitle.caption.grey--text.text--lighten-1 Coming soon
//- v-list-item(to='/preferences', disabled)
//- v-list-item-action: v-icon(color='grey lighten-1') mdi-cog-outline
//- v-list-item-content
//- v-list-item-title Preferences
//- v-list-item-subtitle.caption.grey--text.text--lighten-1 Coming soon
v-list-item(to='/pages', disabled)
v-list-item-action: v-icon(color='grey lighten-1') mdi-file-document
v-list-item-content
......@@ -43,7 +43,7 @@ const router = new VueRouter({
routes: [
{ path: '/', redirect: '/profile' },
{ path: '/profile', component: () => import(/* webpackChunkName: "profile" */ './profile/profile.vue') },
{ path: '/preferences', component: () => import(/* webpackChunkName: "profile" */ './profile/preferences.vue') },
// { path: '/preferences', component: () => import(/* webpackChunkName: "profile" */ './profile/preferences.vue') },
{ path: '/pages', component: () => import(/* webpackChunkName: "profile" */ './profile/pages.vue') },
{ path: '/comments', component: () => import(/* webpackChunkName: "profile" */ './profile/comments.vue') }
]
......@@ -59,6 +59,7 @@ router.afterEach((to, from) => {
})
export default {
i18nOptions: { namespaces: 'profile' },
data() {
return {
profileDrawerShown: true
......
......@@ -26,6 +26,24 @@ module.exports = {
usr.password = ''
usr.tfaSecret = ''
return usr
},
async profile (obj, args, context, info) {
if (!context.req.user || context.req.user.id < 1 || context.req.user.id === 2) {
throw new WIKI.Error.AuthRequired()
}
const usr = await WIKI.models.users.query().findById(context.req.user.id)
if (!usr.isActive) {
throw new WIKI.Error.AuthAccountBanned()
}
const usrGroups = await usr.$relatedQuery('groups')
return {
...usr,
password: '',
providerKey: '',
tfaSecret: '',
lastLoginOn: '1970-01-01',
groups: usrGroups.map(g => g.name)
}
}
},
UserMutation: {
......
......@@ -27,6 +27,8 @@ type UserQuery {
single(
id: Int!
): User @auth(requires: ["manage:users", "manage:system"])
profile: UserProfile
}
# -----------------------------------------------
......@@ -110,3 +112,19 @@ type User {
updatedAt: Date!
groups: [Group]!
}
type UserProfile {
id: Int!
name: String!
email: String!
providerName: String
isSystem: Boolean!
isVerified: Boolean!
location: String!
jobTitle: String!
timezone: String!
createdAt: Date!
updatedAt: Date!
lastLoginOn: Date!
groups: [String]!
}
......@@ -69,6 +69,10 @@ module.exports = {
message: 'You are not authorized to register. Your domain is not whitelisted.',
code: 1011
}),
AuthRequired: CustomError('AuthRequired', {
message: 'You must be authenticated to access this resource.',
code: 1019
}),
AuthTFAFailed: CustomError('AuthTFAFailed', {
message: 'Incorrect TFA Security Code.',
code: 1005
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment