mirror of
https://github.com/wekan/wekan.git
synced 2025-12-29 21:58:49 +01:00
Add createtoken API
This commit is contained in:
parent
4fc2d7b935
commit
a7b43d5b57
4 changed files with 179 additions and 0 deletions
|
|
@ -1760,6 +1760,38 @@ if (Meteor.isServer) {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @operation create_user_token
|
||||
*
|
||||
* @summary Create a user token
|
||||
*
|
||||
* @description Only the admin user (the first user) can call the REST API.
|
||||
*
|
||||
* @param {string} userId the ID of the user to delete
|
||||
* @return_type {_id: string}
|
||||
*/
|
||||
JsonRoutes.add('POST', '/api/createtoken/:userId', function(req, res) {
|
||||
try {
|
||||
Authentication.checkUserId(req.userId);
|
||||
const id = req.params.userId;
|
||||
const token = Accounts._generateStampedLoginToken();
|
||||
Accounts._insertLoginToken(id, token);
|
||||
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: {
|
||||
_id: id,
|
||||
authToken: token.token,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: error,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default Users;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue