Browse Source

changed _id to username for profile access

pull/2/head
Andrew Woodlee 2 years ago
parent
commit
cc7e5ad02f
  1. 6
      app/controllers/user.js
  2. 8
      app/views/components/library.pug
  3. 2
      app/views/components/navbar.pug
  4. 2
      app/views/components/off-canvas.pug

6
app/controllers/user.js

@ -33,12 +33,12 @@ class UserController extends SiteController {
const otpSetup = otpAuthService.middleware('Account', {
adminRequired: false,
otpRequired: true,
otpRedirectURL: async (req) => { return `/user/${req.user._id}`; },
otpRedirectURL: async (req) => { return `/user/${req.user.username}`; },
});
const otpMiddleware = otpAuthService.middleware('Account', {
adminRequired: false,
otpRequired: false,
otpRedirectURL: async (req) => { return `/user/${req.user._id}`; },
otpRedirectURL: async (req) => { return `/user/${req.user.username}`; },
});
router.use(
@ -203,7 +203,7 @@ class UserController extends SiteController {
if (error) {
return next(error);
}
res.redirect(`/user/${res.locals.user._id}`);
res.redirect(`/user/${res.locals.user.username}`);
});
} catch (error) {
this.log.error('failed to create new user', { error });

8
app/views/components/library.pug

@ -40,9 +40,9 @@ include section-title
function getUserProfileUrl (user) {
if (user.core) {
return `/user/core/${user._id}`;
return `/user/core/${user.username}`;
}
return `/user/${user._id}`;
return `/user/${user.username}`;
}
mixin renderCell (label, value, className)
@ -60,6 +60,6 @@ mixin renderBackButton (options)
mixin renderUserLink (user)
if user.coreUserId
a(href=`/user/core/${user._id}`)= `${user.username}@${user.core.meta.domainKey}`
a(href=`/user/core/${user.username}`)= `${user.username}@${user.core.meta.domainKey}`
else
a(href=`/user/${user._id}`)= user.displayName || user.username
a(href=`/user/${user.username}`)= user.displayName || user.username

2
app/views/components/navbar.pug

@ -47,7 +47,7 @@ nav(uk-navbar).uk-navbar-container.uk-position-fixed.uk-position-top
li.uk-nav-heading.uk-text-center= user.displayName || user.username
li.uk-nav-divider
li
a(href= user.core ? `/user/core/${user._id}` : `/user/${user._id}`)
a(href= user.core ? `/user/core/${user.username}` : `/user/${user.username}`)
span.nav-item-icon
i.fas.fa-user
span Profile

2
app/views/components/off-canvas.pug

@ -40,7 +40,7 @@ mixin renderMenuItem (iconClass, label)
.uk-width-expand Chat
li(class={ "uk-active": (currentView === 'user-settings') })
a(href=`/user/${user._id}`).uk-display-block
a(href=`/user/${user.username}`).uk-display-block
div(uk-grid).uk-grid-collapse
.uk-width-auto
.app-menu-icon

Loading…
Cancel
Save