diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-12-13 14:48:11 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-12-13 14:48:21 +0100 |
| commit | a8219611cbebbd27501d9f30c804979048b98107 (patch) | |
| tree | 632dbab8b724f0148b06525771d85ad6ddb55e35 /code/app/src/services/password-reset-service.ts | |
| parent | db2d937a38d5c309e3c6aa14f2eaf3cfe58f415e (diff) | |
| download | greatoffice-a8219611cbebbd27501d9f30c804979048b98107.tar.xz greatoffice-a8219611cbebbd27501d9f30c804979048b98107.zip | |
feat: A whole slew of things
- Use a md5 hash of the session cookie value as key for session validity check
- Introduce global state
- Introduce a common interface for form logic, and implement it on the sign-in form
- Introduce static resolve() on all services instead of new-upping all over.
- Implement /portal on the frontend to support giving the frontend a inital context from server or anywhere.
- Show a notification when users sign in for the first time after validating their email
Diffstat (limited to 'code/app/src/services/password-reset-service.ts')
| -rw-r--r-- | code/app/src/services/password-reset-service.ts | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/code/app/src/services/password-reset-service.ts b/code/app/src/services/password-reset-service.ts index ab3a953..d7700b3 100644 --- a/code/app/src/services/password-reset-service.ts +++ b/code/app/src/services/password-reset-service.ts @@ -1,6 +1,6 @@ -import {http_get_async, http_post_async} from "$api/_fetch"; -import {api_base} from "$configuration"; -import {is_known_problem} from "$models/internal/KnownProblem"; +import { http_get_async, http_post_async } from "$api/_fetch"; +import { api_base } from "$configuration"; +import { is_known_problem } from "$models/internal/KnownProblem"; import type { CreateRequestResponse, FulfillRequestResponse, @@ -9,9 +9,12 @@ import type { } from "./abstractions/IPasswordResetService"; export class PasswordResetService implements IPasswordResetService { + static resolve(): IPasswordResetService { + return new PasswordResetService(); + } async create_request_async(email: string): Promise<CreateRequestResponse> { - const response = await http_post_async(api_base("_/password-reset-request/create"), {email}); - if (response.ok) return {isCreated: true}; + const response = await http_post_async(api_base("_/password-reset-request/create"), { email }); + if (response.ok) return { isCreated: true }; if (is_known_problem(response)) return { isCreated: false, knownProblem: await response.json(), @@ -23,8 +26,8 @@ export class PasswordResetService implements IPasswordResetService { } async fulfill_request_async(id: string, newPassword: string): Promise<FulfillRequestResponse> { - const response = await http_post_async(api_base("_/password-reset-request/fulfill"), {id: id, newPassword}); - if (response.ok) return {isFulfilled: true}; + const response = await http_post_async(api_base("_/password-reset-request/fulfill"), { id: id, newPassword }); + if (response.ok) return { isFulfilled: true }; if (is_known_problem(response)) return { isFulfilled: false, knownProblem: await response.json(), |
