From 0254ae8669019fe3a0d65b387d1843848d381059 Mon Sep 17 00:00:00 2001
From: sidharth <sidhj01@gmail.com>
Date: Tue, 1 Feb 2022 11:36:43 +0530
Subject: [PATCH] env based token

---
 .env.custom          |  1 +
 .env.daily           |  3 ++-
 .env.development     |  3 ++-
 .env.production      |  3 ++-
 .env.staging         |  3 ++-
 git_info.json        |  1 -
 src/services/auth.js | 10 ++++++----
 7 files changed, 15 insertions(+), 9 deletions(-)
 delete mode 100644 git_info.json

diff --git a/.env.custom b/.env.custom
index 1b4ff38..fdbe80e 100644
--- a/.env.custom
+++ b/.env.custom
@@ -21,3 +21,4 @@ VUE_APP_IMAGE_CATEGORY_PARAMS=?height=600&width=600
 VUE_APP_IMAGE_LIB_URL=https://imagelib-api.crane.com
 VUE_APP_CRANE_ORDER_URL=https://order.crane.com
 VUE_APP_BASE_URL=https://www.crane.com
+VUE_APP_RP_AUTH_NAME=rp_auth_stg
\ No newline at end of file
diff --git a/.env.daily b/.env.daily
index da4e057..7014918 100644
--- a/.env.daily
+++ b/.env.daily
@@ -24,4 +24,5 @@ DEPLOY_S3_BUCKET=www-daily.crane.com
 DEPLOY_CLOUDFRONT_ID=E28QEVKG98ZHYU
 VUE_APP_ASSETS_NODESLS_URL=https://assets-sls.crane.com
 VUE_APP_IMAGE_LIB_URL=https://imagelib-api.crane.com
-VUE_APP_BASE_URL=https://www.crane.com
\ No newline at end of file
+VUE_APP_BASE_URL=https://www.crane.com
+VUE_APP_RP_AUTH_NAME=rp_auth_stg
\ No newline at end of file
diff --git a/.env.development b/.env.development
index 19290a9..b81b857 100644
--- a/.env.development
+++ b/.env.development
@@ -24,4 +24,5 @@ DEPLOY_S3_BUCKET=retailer-edge-staging-website-bucket
 DEPLOY_CLOUDFRONT_ID=E1QLFKCOZUDC8P
 VUE_APP_ASSETS_NODESLS_URL=https://assets-stg-sls.crane.com
 VUE_APP_IMAGE_LIB_URL=https://imagelib-stg-api.crane.com
-VUE_APP_BASE_URL=https://retailer-stg.crane.com
\ No newline at end of file
+VUE_APP_BASE_URL=https://retailer-stg.crane.com
+VUE_APP_RP_AUTH_NAME=rp_auth_stg
\ No newline at end of file
diff --git a/.env.production b/.env.production
index be3f63b..7334137 100644
--- a/.env.production
+++ b/.env.production
@@ -25,4 +25,5 @@ DEPLOY_S3_BUCKET=retailer-edge-staging-website-bucket
 DEPLOY_CLOUDFRONT_ID=E1QLFKCOZUDC8P
 VUE_APP_ASSETS_NODESLS_URL=https://assets-stg-sls.crane.com
 VUE_APP_IMAGE_LIB_URL=https://imagelib-stg-api.crane.com
-VUE_APP_BASE_URL=https://retailer-stg.crane.com
\ No newline at end of file
+VUE_APP_BASE_URL=https://retailer-stg.crane.com
+VUE_APP_RP_AUTH_NAME=rp_auth_prod
\ No newline at end of file
diff --git a/.env.staging b/.env.staging
index 1bca5b8..306237f 100644
--- a/.env.staging
+++ b/.env.staging
@@ -25,4 +25,5 @@ DEPLOY_S3_BUCKET=retailer-edge-staging-website-bucket
 DEPLOY_CLOUDFRONT_ID=E1QLFKCOZUDC8P
 VUE_APP_ASSETS_NODESLS_URL=https://assets-stg-sls.crane.com
 VUE_APP_IMAGE_LIB_URL=https://imagelib-stg-api.crane.com
-VUE_APP_BASE_URL=https://retailer-stg.crane.com
\ No newline at end of file
+VUE_APP_BASE_URL=https://retailer-stg.crane.com
+VUE_APP_RP_AUTH_NAME=rp_auth_stg
\ No newline at end of file
diff --git a/git_info.json b/git_info.json
deleted file mode 100644
index 921358c..0000000
--- a/git_info.json
+++ /dev/null
@@ -1 +0,0 @@
-{"branch_name":"dev","last_commit_date":"2022-01-28T12:02:56.000Z","last_commit_author":"anju j","last_commit_hash":"defccce1421feadd75a814a2194b959e791fc6ee"}
\ No newline at end of file
diff --git a/src/services/auth.js b/src/services/auth.js
index 7fadd2e..bac7ed4 100644
--- a/src/services/auth.js
+++ b/src/services/auth.js
@@ -1,7 +1,9 @@
 import { Base64 } from 'js-base64';
+const rpAuthName = process.env.VUE_APP_RP_AUTH_NAME;
+console.log("rpAuthName",rpAuthName)
 const getAuthUser = function() {
     // return authorization header with jwt token
-    const userAuthEncoded = window.$cookies.get('cr_cauth');
+    const userAuthEncoded = window.$cookies.get(rpAuthName);
     if (userAuthEncoded === null) {
         return null;
     }
@@ -19,12 +21,12 @@ const setAuthUser = function(userAuth,flag) {
     if(flag)
     {
         const userAuthEncoded = Base64.encode(JSON.stringify(userAuth));
-        window.$cookies.set("cr_cauth", userAuthEncoded, '30d', null, getDomain(window.location.hostname));
+        window.$cookies.set(rpAuthName, userAuthEncoded, '30d', null, getDomain(window.location.hostname));
     }
     else
     {
         const userAuthEncoded = Base64.encode(JSON.stringify(userAuth));
-        window.$cookies.set("cr_cauth", userAuthEncoded, '1h', null, getDomain(window.location.hostname));
+        window.$cookies.set(rpAuthName, userAuthEncoded, '1h', null, getDomain(window.location.hostname));
     }
    
 }
@@ -33,7 +35,7 @@ const resetAuthUser = function() {
     if (au === null) {
         return false;
     }
-    window.$cookies.remove('cr_cauth', null, getDomain(window.location.hostname));
+    window.$cookies.remove(rpAuthName, null, getDomain(window.location.hostname));
 }
 
 const authHeader = function() {