perms + tell the client to re-auth after passwd change

This commit is contained in:
Erik 2023-07-18 17:11:25 +03:00
parent 9f6df93d9f
commit eafae55e35
Signed by: Navy.gif
GPG Key ID: 2532FBBB61C65A68

View File

@ -69,9 +69,9 @@ class UserEndpoint extends ApiEndpoint
[ 'get', '/connect/:service/finalise', this.connectOAuthFinalise.bind(this) ],
// Applications
[ 'get', '/applications', this.applications.bind(this) ],
[ 'get', '/applications', this.applications.bind(this), [ server.auth.createAuthoriser('applications', 5) ]],
[ 'post', '/applications', this.createApplication.bind(this), [ server.auth.createAuthoriser('applications:create', 5) ]],
[ 'delete', '/applications/:id', this.deleteApplication.bind(this) ],
[ 'delete', '/applications/:id', this.deleteApplication.bind(this), [ server.auth.createAuthoriser('applications', 5) ]],
];
this.middleware = [
@ -151,11 +151,21 @@ class UserEndpoint extends ApiEndpoint
return res.status(400).send('Username taken');
user.name = body.username;
}
if (body.newPassword)
await user.setPassword(body.newPassword);
if (body.displayName !== user.displayName)
user.displayName = body.displayName;
if (body.newPassword)
{
await user.setPassword(body.newPassword, true);
req.session.destroy(() =>
{
res.json({ reAuth: true });
});
return;
}
await user.save();
return res.end();