Skip to content

Commit

Permalink
Merge pull request #2365 from shubhambansaltarento/master-new
Browse files Browse the repository at this point in the history
Update jwtHelper in master and readme file
  • Loading branch information
vinukumar-vs authored Jul 5, 2024
2 parents a4f7a04 + 0f66c3a commit 320272c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Pre-requisites

Before you install creation portal on your laptop, examine your environment and gather data to ensure an optimal installation experience. Review the [details](https://app.gitbook.com/o/-Mi9QwJlsfb7xuxTBc0J/s/SjljYc0PyD64vGgDlMl4/use/system-requirements) to ensure that the environment has the necessary resources and compliant target systems to successfully install and run creation portal.
Before you install creation portal on your laptop, examine your environment and gather data to ensure an optimal installation experience. Review the [details](https://sunbird.gitbook.io/sunbird-cokreat-1/v/release-7.0.0-draft-1/use/developer-guide/reference-cokreat-web-app/reference-cokreat-web-app/installation-guide/ubuntu-or-mac-installation) to ensure that the environment has the necessary resources and compliant target systems to successfully install and run creation portal.

Note: For Apple Mac M1 chip set please reffer the microsite installation guidelines

## Project Setup

Expand Down Expand Up @@ -58,6 +60,7 @@ Before you install creation portal on your laptop, examine your environment and
5. Edit the Application Configuration

> Open `<PROJECT-FOLDER>/src/app/helpers/environmentVariablesHelper.js` in any available text editor and update the contents of the file so that it contains exactly the following values
> Note: Environment variables are dependent on your infra and may change please contact the infra person for updated environment variables

```console
module.exports = {
Expand All @@ -84,7 +87,7 @@ Before you install creation portal on your laptop, examine your environment and
1. Creation portal or web application

1. Run the following command in the **{PROJECT-FOLDER}/src/app/client** folder
2. $ nodemon
2. ng build --watch=true
3. Wait for the build process to complete before proceeding to the next step. The following messge should appear on the screeen
```console
[nodemon] clean exit - waiting for changes before restart
Expand All @@ -93,7 +96,7 @@ Before you install creation portal on your laptop, examine your environment and
2. Services stack or the backend API interface

1. Run the following command in the **{PROJECT-FOLDER}/src/app** folder
2. $ node server.js
2. npm run server

3. The local HTTP server is launched at `http://localhost:3000`

Expand Down
27 changes: 27 additions & 0 deletions src/app/helpers/jwtHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const jwt = require('jsonwebtoken');

/**
*
* @param accessToken
* @returns {*}
*/
const getUserIdFromToken = (accessToken) => {
var jwtPayload = jwt.decode(accessToken);
if (jwtPayload && jwtPayload.sub) {
var splittedSub = jwtPayload.sub.split(':');
return splittedSub[splittedSub.length - 1]
} else {
return null;
}
};

/**
* JWT token to decode
* @param token
* @returns {null|{payload, signature, header}}
*/
const decodeToken = (token) => {
return jwt.decode(token);
};

module.exports = {getUserIdFromToken, decodeToken};

0 comments on commit 320272c

Please sign in to comment.