🔀 Merge pull request #892 from Cereal916/dashyAuthTokenUniqueKey

Make auth cookie key more unique to avoid collisions with other apps …
This commit is contained in:
Alicia Sykes 2022-09-10 20:40:36 +01:00 committed by GitHub
commit 89a06afe1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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);
};
@ -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);
};

View File

@ -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: {