Implement frontend session routing flow
- Validate and prepare access links in apps/frontend - Add session, ended, and unauthorized routes with polling - Copy full public access URLs from the admin links page
This commit is contained in:
@@ -1,8 +1,3 @@
|
||||
import { errAsync, ResultAsync } from "neverthrow";
|
||||
import { nanoid } from "nanoid";
|
||||
import { db } from "@pkg/db";
|
||||
import { type Err } from "@pkg/result";
|
||||
import { FlowExecCtx } from "@core/flow.execution.context";
|
||||
import {
|
||||
CreateLink,
|
||||
Link,
|
||||
@@ -10,8 +5,13 @@ import {
|
||||
LinkWithDevice,
|
||||
UpdateLink,
|
||||
} from "./data";
|
||||
import { FlowExecCtx } from "@core/flow.execution.context";
|
||||
import { errAsync, ResultAsync } from "neverthrow";
|
||||
import { LinkRepository } from "./repository";
|
||||
import { type Err } from "@pkg/result";
|
||||
import { linkErrors } from "./errors";
|
||||
import { nanoid } from "nanoid";
|
||||
import { db } from "@pkg/db";
|
||||
|
||||
export class LinkController {
|
||||
constructor(private repo: LinkRepository) {}
|
||||
@@ -26,9 +26,12 @@ export class LinkController {
|
||||
|
||||
/**
|
||||
* Fetch a link by its URL token, including the joined device.
|
||||
* Used by apps/front to validate and resolve an incoming link.
|
||||
* Used by apps/frontend to validate and resolve an incoming link.
|
||||
*/
|
||||
getByToken(fctx: FlowExecCtx, token: string): ResultAsync<LinkWithDevice, Err> {
|
||||
getByToken(
|
||||
fctx: FlowExecCtx,
|
||||
token: string,
|
||||
): ResultAsync<LinkWithDevice, Err> {
|
||||
return this.repo.getByToken(fctx, token);
|
||||
}
|
||||
|
||||
@@ -36,7 +39,10 @@ export class LinkController {
|
||||
* Validate a token: must exist, be active, and not be expired.
|
||||
* Returns the resolved link+device on success.
|
||||
*/
|
||||
validate(fctx: FlowExecCtx, token: string): ResultAsync<LinkWithDevice, Err> {
|
||||
validate(
|
||||
fctx: FlowExecCtx,
|
||||
token: string,
|
||||
): ResultAsync<LinkWithDevice, Err> {
|
||||
return this.repo.getByToken(fctx, token).andThen((l) => {
|
||||
if (l.status !== LinkStatus.ACTIVE) {
|
||||
return errAsync(linkErrors.linkNotActive(fctx, token));
|
||||
|
||||
Reference in New Issue
Block a user