Adding state perameter to /api/client/user endpoint
This commit is contained in:
parent
2b9eb6e974
commit
67dde954cc
@ -8,20 +8,23 @@ import { createJWT } from "../../keys";
|
||||
const ClientRouter = Router();
|
||||
/**
|
||||
* @api {get} /client/user
|
||||
* @apiName ClientUser
|
||||
*
|
||||
* @apiGroup client
|
||||
* @apiPermission user_client Requires ClientID and Authenticated User
|
||||
*
|
||||
* @apiParam {String} redirect_uri URL to redirect to on success
|
||||
* @apiParam {String} state A optional state, that will be included in the JWT and redirect_uri as parameter
|
||||
*
|
||||
* @apiName ClientUser
|
||||
* @apiGroup client
|
||||
*
|
||||
* @apiPermission user_client Requires ClientID and Authenticated User
|
||||
*/
|
||||
ClientRouter.get("/user", Stacker(GetClientAuthMiddleware(false), GetUserMiddleware(true, false), async (req: Request, res: Response) => {
|
||||
let { redirect_uri, state } = req.query;
|
||||
let jwt = await createJWT({
|
||||
client: req.client.client_id,
|
||||
uid: req.user.uid,
|
||||
username: req.user.username
|
||||
username: req.user.username,
|
||||
state: state
|
||||
}, 30); //after 30 seconds this token is invalid
|
||||
res.redirect(req.query.redirect_uri + "?jwt=" + jwt)
|
||||
res.redirect(redirect_uri + "?jwt=" + jwt + (state ? `&state=${state}` : ""));
|
||||
}));
|
||||
|
||||
export default ClientRouter;
|
Loading…
Reference in New Issue
Block a user