mirror of
https://github.com/Lissy93/dashy.git
synced 2024-12-29 20:11:53 +03:00
🐛 Normalize data prior to calculatin SHA hash
This commit is contained in:
parent
ba2ac7661d
commit
353bb618b4
@ -6,7 +6,11 @@ import { cookieKeys, localStorageKeys } from './defaults';
|
|||||||
* @param {String} user The username of user
|
* @param {String} user The username of user
|
||||||
* @returns {String} The hashed token
|
* @returns {String} The hashed token
|
||||||
*/
|
*/
|
||||||
const generateUserToken = (user) => sha256(user.toString()).toString().toLowerCase();
|
const generateUserToken = (user) => {
|
||||||
|
const strAndUpper = (input) => input.toString().toUpperCase();
|
||||||
|
const sha = sha256(strAndUpper(user.user) + strAndUpper(user.hash));
|
||||||
|
return strAndUpper(sha);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the user is currently authenticated
|
* Checks if the user is currently authenticated
|
||||||
@ -47,7 +51,7 @@ export const checkCredentials = (username, pass, users) => {
|
|||||||
response = { correct: false, msg: 'Missing Password' };
|
response = { correct: false, msg: 'Missing Password' };
|
||||||
} else {
|
} else {
|
||||||
users.forEach((user) => {
|
users.forEach((user) => {
|
||||||
if (user.user === username) {
|
if (user.user.toLowerCase() === username.toLowerCase()) {
|
||||||
if (user.hash.toLowerCase() === sha256(pass).toString().toLowerCase()) {
|
if (user.hash.toLowerCase() === sha256(pass).toString().toLowerCase()) {
|
||||||
response = { correct: true, msg: 'Logging in...' };
|
response = { correct: true, msg: 'Logging in...' };
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user