Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Kelp GUI: allow multiple users on frontend via getUserData() localsto…
Browse files Browse the repository at this point in the history
…rage method (closes #686) (#690)

* 1 - add logic to create and read user_id from localStorage

* 2 - add uuid dependency to package.json (via npm install)

* 3 - updated yarn lock file after building frontend

* 4 - fix import statement of uuid
  • Loading branch information
nikhilsaraf authored Apr 9, 2021
1 parent 0bc17c7 commit be0dc55
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gui/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"react-router-dom": "^5.0.0",
"react-scripts": "2.1.8",
"react-tooltip-lite": "^1.10.0",
"stellar-sdk": "^3.0.0"
"stellar-sdk": "^3.0.0",
"uuid": "^8.3.2"
},
"scripts": {
"start": "react-scripts start",
Expand Down
12 changes: 11 additions & 1 deletion gui/web/src/kelp-ops-api/getUserData.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { v4 as uuidv4 } from "uuid";

export default () => {
const userIDKey = 'user_id';

let userId = localStorage.getItem(userIDKey);
if (userId == null) {
userId = uuidv4();
localStorage.setItem(userIDKey, userId);
}

return {
ID: "1347129431489",
ID: userId,
};
};
5 changes: 5 additions & 0 deletions gui/web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10307,6 +10307,11 @@ uuid@^3.0.1, uuid@^3.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==

uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

validate-npm-package-license@^3.0.1:
version "3.0.4"
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"
Expand Down

0 comments on commit be0dc55

Please sign in to comment.