impersonation
This commit is contained in:
parent
cec98a5016
commit
2707ac5773
2 changed files with 31 additions and 11 deletions
|
@ -118,6 +118,18 @@ module.exports = (db) => {
|
|||
}
|
||||
})
|
||||
|
||||
router.post('/edit/impersonate/:userToEdit', verifyAuth(), async (req, res) => {
|
||||
if (!req.user.admin) return res.redirect('/');
|
||||
req.login({ _id: req.params.userToEdit }, err => {
|
||||
if (err) {
|
||||
req.flash('error', err.message)
|
||||
return res.redirect(`/admin-settings/edit/${req.params.userToEdit}`)
|
||||
}
|
||||
req.flash('success', `You are now ${req.params.userToEdit}.`)
|
||||
res.redirect('/')
|
||||
})
|
||||
});
|
||||
|
||||
router.post('/edit/remove/:userToRemove', verifyAuth(), async (req, res) => {
|
||||
if (!req.user.admin) return res.redirect('/');
|
||||
const doc = await db.get(req.params.userToRemove);
|
||||
|
|
|
@ -31,17 +31,25 @@ block content
|
|||
input.button.is-rounded(type='submit', value='Generate New Link')
|
||||
.level-item
|
||||
a(href=signupLink, style='font-family: monospaced; word-break: break-all;')= signupLink
|
||||
h2 Change Name
|
||||
form(action=`${_CC.config.base}admin-settings/edit/rename/${user._id}`, method='POST')
|
||||
.field
|
||||
label.label Username
|
||||
.control.has-icons-left
|
||||
input.input(type='text', name='newUsername', placeholder=user._id, value=user._id)
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-user
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value='Change Username')
|
||||
.columns
|
||||
.column.is-narrow
|
||||
h2 Change Name
|
||||
form(action=`${_CC.config.base}admin-settings/edit/rename/${user._id}`, method='POST')
|
||||
.field
|
||||
label.label Username
|
||||
.control.has-icons-left
|
||||
input.input(type='text', name='newUsername', placeholder=user._id, value=user._id)
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-user
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value='Change Username')
|
||||
.column.is-narrow
|
||||
h2 Impersonate
|
||||
form(action=`${_CC.config.base}admin-settings/edit/impersonate/${user._id}`, method='POST')
|
||||
.field
|
||||
.control
|
||||
input.input.button.is-warning(type='submit', value=`Log in as ${user._id}`, style='margin-top: 1em;')
|
||||
h2(style='margin-bottom: 1em;') Reset Password
|
||||
if user.pwToken
|
||||
- const resetLink = `${_CC.config.base}resetpw/${user.pwToken}`
|
||||
|
|
Loading…
Reference in a new issue