redesign login/registration. add autologin from registration. add 'continue' register from accept acc
This commit is contained in:
43
src/renderer/utils/pendingVerification.ts
Normal file
43
src/renderer/utils/pendingVerification.ts
Normal file
@ -0,0 +1,43 @@
|
||||
export type PendingVerification = {
|
||||
username: string;
|
||||
password?: string;
|
||||
createdAt: number;
|
||||
};
|
||||
|
||||
const PENDING_KEY = 'pending_verifications_v1';
|
||||
|
||||
export const loadPending = (): PendingVerification[] => {
|
||||
try {
|
||||
const raw = localStorage.getItem(PENDING_KEY);
|
||||
return raw ? (JSON.parse(raw) as PendingVerification[]) : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
const savePending = (items: PendingVerification[]) => {
|
||||
localStorage.setItem(PENDING_KEY, JSON.stringify(items));
|
||||
};
|
||||
|
||||
export const upsertPending = (item: PendingVerification) => {
|
||||
const list = loadPending();
|
||||
const next = [
|
||||
item,
|
||||
...list.filter(
|
||||
(x) => x.username.toLowerCase() !== item.username.toLowerCase(),
|
||||
),
|
||||
].slice(0, 5);
|
||||
|
||||
savePending(next);
|
||||
};
|
||||
|
||||
export const removePending = (username: string) => {
|
||||
const list = loadPending();
|
||||
savePending(
|
||||
list.filter((x) => x.username.toLowerCase() !== username.toLowerCase()),
|
||||
);
|
||||
};
|
||||
|
||||
export const clearPending = () => {
|
||||
localStorage.removeItem(PENDING_KEY);
|
||||
};
|
||||
Reference in New Issue
Block a user