mirror of
https://github.com/Lissy93/dashy.git
synced 2024-12-01 04:33:02 +03:00
Make auth cookie key more unique to avoid collisions with other apps running on the same server.
This commit is contained in:
parent
8d300d42a4
commit
a9adddc0ce
@ -125,7 +125,7 @@ export const login = (username, pass, timeout) => {
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
const expiry = new Date(now.setTime(now.getTime() + timeout)).toGMTString();
|
const expiry = new Date(now.setTime(now.getTime() + timeout)).toGMTString();
|
||||||
const userObject = { user: username, hash: sha256(pass).toString().toLowerCase() };
|
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}` : ''}`;
|
+ `${timeout > 0 ? `expires=${expiry}` : ''}`;
|
||||||
localStorage.setItem(localStorageKeys.USERNAME, username);
|
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
|
* Removed the browsers' cookie, causing user to be logged out
|
||||||
*/
|
*/
|
||||||
export const logout = () => {
|
export const logout = () => {
|
||||||
document.cookie = 'authenticationToken=null';
|
document.cookie = `${cookieKeys.AUTH_TOKEN}=null`;
|
||||||
localStorage.removeItem(localStorageKeys.USERNAME);
|
localStorage.removeItem(localStorageKeys.USERNAME);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
/* Key names for cookie identifiers */
|
/* Key names for cookie identifiers */
|
||||||
cookieKeys: {
|
cookieKeys: {
|
||||||
AUTH_TOKEN: 'authenticationToken',
|
AUTH_TOKEN: 'dashyAuthToken',
|
||||||
},
|
},
|
||||||
/* Key names for session storage identifiers */
|
/* Key names for session storage identifiers */
|
||||||
sessionStorageKeys: {
|
sessionStorageKeys: {
|
||||||
|
Loading…
Reference in New Issue
Block a user