i went overboard
This commit is contained in:
parent
ca31bba520
commit
1fcbbaab55
1 changed files with 2 additions and 2 deletions
|
@ -49,7 +49,7 @@ export class ApiLogins extends BaseRepository {
|
||||||
// Generate random login id
|
// Generate random login id
|
||||||
let loginId;
|
let loginId;
|
||||||
while (true) {
|
while (true) {
|
||||||
loginId = randomBytes(64).toString("hex");
|
loginId = randomBytes(16).toString("hex");
|
||||||
const existing = await this.apiLogins.findOne({
|
const existing = await this.apiLogins.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: loginId,
|
id: loginId,
|
||||||
|
@ -59,7 +59,7 @@ export class ApiLogins extends BaseRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate token
|
// Generate token
|
||||||
const token = randomBytes(64).toString("hex");
|
const token = randomBytes(32).toString("hex");
|
||||||
const hash = crypto.createHash("sha256");
|
const hash = crypto.createHash("sha256");
|
||||||
hash.update(loginId + token); // Use loginId as a salt
|
hash.update(loginId + token); // Use loginId as a salt
|
||||||
const hashedToken = hash.digest("hex");
|
const hashedToken = hash.digest("hex");
|
||||||
|
|
Loading…
Add table
Reference in a new issue