@loomcore/api 0.2.28 → 0.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IModelSpec } from "@loomcore/common/models";
|
|
1
|
+
import { type ILoginResponse, type IModelSpec } from "@loomcore/common/models";
|
|
2
2
|
import type { Application, Request, Response } from "express";
|
|
3
3
|
import type { IDatabase } from "../databases/models/index.js";
|
|
4
4
|
import { OrganizationService, UserService } from "../services/index.js";
|
|
@@ -21,7 +21,7 @@ export declare class AuthController {
|
|
|
21
21
|
login(req: Request, res: Response): Promise<void>;
|
|
22
22
|
requestTokenUsingRefreshToken(req: Request, res: Response): Promise<void>;
|
|
23
23
|
getUserContext(req: Request, res: Response): Promise<void>;
|
|
24
|
-
afterAuth(_req: Request, _res: Response, _loginResponse:
|
|
24
|
+
afterAuth(_req: Request, _res: Response, _loginResponse: ILoginResponse): Promise<void>;
|
|
25
25
|
changePassword(req: Request, res: Response): Promise<void>;
|
|
26
26
|
forgotPassword(req: Request, res: Response): Promise<void>;
|
|
27
27
|
resetPassword(req: Request, res: Response): Promise<void>;
|
|
@@ -77,7 +77,7 @@ let AuthController = (() => {
|
|
|
77
77
|
}
|
|
78
78
|
mapRoutes(app) {
|
|
79
79
|
const authorize = (method) => authorizeMethod(this, method);
|
|
80
|
-
app.post(`/api/auth/login`, this.login.bind(this)
|
|
80
|
+
app.post(`/api/auth/login`, this.login.bind(this));
|
|
81
81
|
app.get(`/api/auth/refresh`, this.requestTokenUsingRefreshToken.bind(this));
|
|
82
82
|
app.get(`/api/auth/get-user-context`, authorize('getUserContext'), this.getUserContext.bind(this));
|
|
83
83
|
app.patch(`/api/auth/change-password`, authorize('changePassword'), this.changePassword.bind(this));
|
|
@@ -106,6 +106,7 @@ let AuthController = (() => {
|
|
|
106
106
|
res.set("Content-Type", "application/json");
|
|
107
107
|
const deviceId = getAndSetDeviceIdCookie(req, res);
|
|
108
108
|
const loginResponse = await attemptLogin(this.database, email, password, deviceId, organization, this.userService);
|
|
109
|
+
await this.afterAuth(req, res, loginResponse);
|
|
109
110
|
apiUtils.apiResponse(res, 200, { data: loginResponse }, this.loginResponseSpec);
|
|
110
111
|
}
|
|
111
112
|
async requestTokenUsingRefreshToken(req, res) {
|
|
@@ -128,9 +129,7 @@ let AuthController = (() => {
|
|
|
128
129
|
const userContext = req.userContext;
|
|
129
130
|
apiUtils.apiResponse(res, 200, { data: userContext }, this.userContextSpec);
|
|
130
131
|
}
|
|
131
|
-
afterAuth(_req, _res, _loginResponse) {
|
|
132
|
-
console.log("in afterAuth");
|
|
133
|
-
}
|
|
132
|
+
async afterAuth(_req, _res, _loginResponse) { }
|
|
134
133
|
async changePassword(req, res) {
|
|
135
134
|
const userContext = req.userContext;
|
|
136
135
|
if (!userContext) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ILoginResponse, type IOrganization } from "@loomcore/common/models";
|
|
2
2
|
import type { IDatabase } from "../../databases/models/index.js";
|
|
3
3
|
import { UserService } from "../../services/user.service.js";
|
|
4
|
-
export declare function attemptLogin(database: IDatabase, email: string, password: string, deviceId: string, organization: IOrganization | null, userService?: UserService): Promise<ILoginResponse
|
|
4
|
+
export declare function attemptLogin(database: IDatabase, email: string, password: string, deviceId: string, organization: IOrganization | null, userService?: UserService): Promise<ILoginResponse>;
|