Skip to content

Commit

Permalink
πŸ”€ Merge pull request #892 from Cereal916/dashyAuthTokenUniqueKey
Browse files Browse the repository at this point in the history
Make auth cookie key more unique to avoid collisions with other apps …
  • Loading branch information
Lissy93 authored Sep 10, 2022
2 parents 8d300d4 + a9adddc commit 89a06af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/utils/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const login = (username, pass, timeout) => {
const now = new Date();
const expiry = new Date(now.setTime(now.getTime() + timeout)).toGMTString();
const userObject = { user: username, hash: sha256(pass).toString().toLowerCase() };
document.cookie = `authenticationToken=${generateUserToken(userObject)};`
document.cookie = `${cookieKeys.AUTH_TOKEN}=${generateUserToken(userObject)};`
+ `${timeout > 0 ? `expires=${expiry}` : ''}`;
localStorage.setItem(localStorageKeys.USERNAME, username);
};
Expand All @@ -134,7 +134,7 @@ export const login = (username, pass, timeout) => {
* Removed the browsers' cookie, causing user to be logged out
*/
export const logout = () => {
document.cookie = 'authenticationToken=null';
document.cookie = `${cookieKeys.AUTH_TOKEN}=null`;
localStorage.removeItem(localStorageKeys.USERNAME);
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module.exports = {
},
/* Key names for cookie identifiers */
cookieKeys: {
AUTH_TOKEN: 'authenticationToken',
AUTH_TOKEN: 'dashyAuthToken',
},
/* Key names for session storage identifiers */
sessionStorageKeys: {
Expand Down

0 comments on commit 89a06af

Please sign in to comment.