mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
feat(api): ✨ Implement password resets
This commit is contained in:
parent
1365987a1c
commit
24288c95b5
11 changed files with 1998 additions and 19 deletions
|
|
@ -169,12 +169,14 @@ export const configValidator = z.object({
|
|||
login: zUrlPath.default("/oauth/authorize"),
|
||||
consent: zUrlPath.default("/oauth/consent"),
|
||||
register: zUrlPath.default("/register"),
|
||||
password_reset: zUrlPath.default("/oauth/reset"),
|
||||
})
|
||||
.default({
|
||||
home: "/",
|
||||
login: "/oauth/authorize",
|
||||
consent: "/oauth/consent",
|
||||
register: "/register",
|
||||
password_reset: "/oauth/reset",
|
||||
}),
|
||||
settings: z.record(z.string(), z.any()).default({}),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { randomBytes } from "node:crypto";
|
||||
import { idValidator } from "@api";
|
||||
import { getBestContentType, urlToContentFormat } from "@content_types";
|
||||
import type { EntityValidator } from "@lysand-org/federation";
|
||||
|
|
@ -150,6 +151,16 @@ export class User {
|
|||
)[0];
|
||||
}
|
||||
|
||||
async resetPassword() {
|
||||
const resetToken = await randomBytes(32).toString("hex");
|
||||
|
||||
await this.update({
|
||||
passwordResetToken: resetToken,
|
||||
});
|
||||
|
||||
return resetToken;
|
||||
}
|
||||
|
||||
async pin(note: Note) {
|
||||
return (
|
||||
await db
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue