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) => {
|
router.post('/edit/remove/:userToRemove', verifyAuth(), async (req, res) => {
|
||||||
if (!req.user.admin) return res.redirect('/');
|
if (!req.user.admin) return res.redirect('/');
|
||||||
const doc = await db.get(req.params.userToRemove);
|
const doc = await db.get(req.params.userToRemove);
|
||||||
|
|
|
@ -31,17 +31,25 @@ block content
|
||||||
input.button.is-rounded(type='submit', value='Generate New Link')
|
input.button.is-rounded(type='submit', value='Generate New Link')
|
||||||
.level-item
|
.level-item
|
||||||
a(href=signupLink, style='font-family: monospaced; word-break: break-all;')= signupLink
|
a(href=signupLink, style='font-family: monospaced; word-break: break-all;')= signupLink
|
||||||
h2 Change Name
|
.columns
|
||||||
form(action=`${_CC.config.base}admin-settings/edit/rename/${user._id}`, method='POST')
|
.column.is-narrow
|
||||||
.field
|
h2 Change Name
|
||||||
label.label Username
|
form(action=`${_CC.config.base}admin-settings/edit/rename/${user._id}`, method='POST')
|
||||||
.control.has-icons-left
|
.field
|
||||||
input.input(type='text', name='newUsername', placeholder=user._id, value=user._id)
|
label.label Username
|
||||||
span.icon.is-small.is-left
|
.control.has-icons-left
|
||||||
i.fas.fa-user
|
input.input(type='text', name='newUsername', placeholder=user._id, value=user._id)
|
||||||
.field
|
span.icon.is-small.is-left
|
||||||
.control
|
i.fas.fa-user
|
||||||
input.button.is-primary(type='submit' value='Change Username')
|
.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
|
h2(style='margin-bottom: 1em;') Reset Password
|
||||||
if user.pwToken
|
if user.pwToken
|
||||||
- const resetLink = `${_CC.config.base}resetpw/${user.pwToken}`
|
- const resetLink = `${_CC.config.base}resetpw/${user.pwToken}`
|
||||||
|
|
Loading…
Reference in a new issue