-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure maps API key is properly retrieved and retained
- Loading branch information
1 parent
bae3ae1
commit 3782bfe
Showing
10 changed files
with
82 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,21 @@ | ||
import { setStorageValue, getStorageValue, clearStorageValue } from "./storage"; | ||
|
||
/** | ||
* Store the JWT token | ||
* @param {*} token | ||
*/ | ||
const apiSetToken = (token) => { | ||
// TODO: Move to HTTP Cookie | ||
localStorage.setItem("token", token); | ||
}; | ||
const apiSetToken = (token) => setStorageValue("token", token); | ||
|
||
/** | ||
* Retrieve the current JWT token | ||
* @param {*} token | ||
* @returns | ||
*/ | ||
const apiGetToken = () => { | ||
try { | ||
// TODO: Move to HTTP Cookie | ||
const token = localStorage.getItem("token"); | ||
return token; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
const apiGetToken = () => getStorageValue("token"); | ||
|
||
/** | ||
* Clear the current JWT token | ||
*/ | ||
const apiClearToken = () => { | ||
// TODO: Move to HTTP Cookie | ||
localStorage.removeItem("token"); | ||
}; | ||
const apiClearToken = () => clearStorageValue("token"); | ||
|
||
export { apiClearToken, apiSetToken, apiGetToken }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Convert a name that may be mixed case and with spaces to a local storage key | ||
* @param {*} name | ||
* @returns | ||
*/ | ||
const getStorageKey = (name) => { | ||
const key = name.toLowerCase().replace(/ /g, "-"); | ||
return key; | ||
}; | ||
|
||
/** | ||
* Store a named value | ||
* @param {*} token | ||
* @param {*} value | ||
*/ | ||
const setStorageValue = (name, value) => { | ||
const key = getStorageKey(name); | ||
localStorage.setItem(key, value); | ||
}; | ||
|
||
/** | ||
* Retrieve a stored value | ||
* @param {*} name | ||
* @returns | ||
*/ | ||
const getStorageValue = (name) => { | ||
try { | ||
const key = getStorageKey(name); | ||
const token = localStorage.getItem(key); | ||
return token; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
||
/** | ||
* Clear a named storage value | ||
* @param {*} name | ||
*/ | ||
const clearStorageValue = (name) => { | ||
const key = getStorageKey(name); | ||
localStorage.removeItem(key); | ||
}; | ||
|
||
export { setStorageValue, getStorageValue, clearStorageValue }; |
This file was deleted.
Oops, something went wrong.