Merge pull request #3520 from messagerie-melanie2/master

Add createtoken API
This commit is contained in:
Lauri Ojansivu 2021-02-02 20:48:00 +02:00 committed by GitHub
commit d8c8856548
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 2 deletions

View file

@ -385,8 +385,8 @@ export class ExporterExcel {
}
//add data +8 hours
function addTZhours(jdate) {
let curdate = new Date(jdate);
let checkCorrectDate = moment(curdate);
const curdate = new Date(jdate);
const checkCorrectDate = moment(curdate);
if (checkCorrectDate.isValid()) {
return curdate;
} else {

View file

@ -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;

BIN
photorec.ses Normal file

Binary file not shown.

View file

@ -245,6 +245,46 @@ paths:
type: string
defaultSwimlaneId:
type: string
/api/createtoken/{user}:
post:
operationId: createtoken
summary: CreateToken for a user with REST API
description: |
Only the admin user (the first user) can call the REST API.
consumes:
- application/x-www-form-urlencoded
- application/json
tags:
- Login
parameters:
- name: user
in: path
description: |
the user ID
type: string
required: true
responses:
200:
description: |-
Successful
schema:
items:
properties:
id:
type: string
token:
type: string
400:
description: |
Error
schema:
items:
properties:
error:
type: number
reason:
type: string
/api/boards/{board}:
get:
operationId: get_board