feat: reset password cli (#903)
* feat: add password reset cli * feat: add homarr cli to docker image
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { randomUUID } from "crypto";
|
||||
import type { Session } from "next-auth";
|
||||
|
||||
import { generateSecureRandomToken } from "@homarr/common/server";
|
||||
import type { Database } from "@homarr/db";
|
||||
|
||||
import { getCurrentUserPermissionsAsync } from "./callbacks";
|
||||
@@ -13,7 +13,7 @@ export const expireDateAfter = (seconds: number) => {
|
||||
};
|
||||
|
||||
export const generateSessionToken = () => {
|
||||
return randomUUID();
|
||||
return generateSecureRandomToken(48);
|
||||
};
|
||||
|
||||
export const getSessionFromTokenAsync = async (db: Database, token: string | undefined): Promise<Session | null> => {
|
||||
|
||||
@@ -30,7 +30,12 @@ describe("expireDateAfter should calculate date after specified seconds", () =>
|
||||
describe("generateSessionToken should return a random UUID", () => {
|
||||
it("should return a random UUID", () => {
|
||||
const result = generateSessionToken();
|
||||
expect(z.string().uuid().safeParse(result).success).toBe(true);
|
||||
expect(
|
||||
z
|
||||
.string()
|
||||
.regex(/^[a-f0-9]+$/)
|
||||
.safeParse(result).success,
|
||||
).toBe(true);
|
||||
});
|
||||
it("should return a different token each time", () => {
|
||||
const result1 = generateSessionToken();
|
||||
|
||||
Reference in New Issue
Block a user