@greatapps/common 1.1.66 → 1.1.67
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,9 +1,17 @@
|
|
|
1
1
|
"use server";
|
|
2
2
|
import { authService } from "../services/auth.service";
|
|
3
3
|
import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
|
|
4
|
+
import { ApiError } from "../../../infra/api/types";
|
|
4
5
|
async function loginAction(credentials) {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
try {
|
|
7
|
+
const clientInfo = await getClientInfoFromRequest();
|
|
8
|
+
return await authService.login(credentials, clientInfo);
|
|
9
|
+
} catch (error) {
|
|
10
|
+
if (error instanceof ApiError) {
|
|
11
|
+
throw new Error(error.message);
|
|
12
|
+
}
|
|
13
|
+
throw new Error("Erro ao realizar login. Tente novamente.");
|
|
14
|
+
}
|
|
7
15
|
}
|
|
8
16
|
export {
|
|
9
17
|
loginAction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/auth/actions/login.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { authService } from '../services/auth.service';\r\nimport { LoginRequest, LoginResponse } from '../schema';\r\nimport { getClientInfoFromRequest } from '../../../infra/utils/client-info';\r\n\r\nexport async function loginAction(credentials: LoginRequest): Promise<LoginResponse> {\r\n const clientInfo = await getClientInfoFromRequest();\r\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/auth/actions/login.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { authService } from '../services/auth.service';\r\nimport { LoginRequest, LoginResponse } from '../schema';\r\nimport { getClientInfoFromRequest } from '../../../infra/utils/client-info';\r\nimport { ApiError } from '../../../infra/api/types';\r\n\r\nexport async function loginAction(credentials: LoginRequest): Promise<LoginResponse> {\r\n try {\r\n const clientInfo = await getClientInfoFromRequest();\r\n return await authService.login(credentials, clientInfo);\r\n } catch (error) {\r\n if (error instanceof ApiError) {\r\n throw new Error(error.message); // Error puro propaga a mensagem\r\n }\r\n throw new Error('Erro ao realizar login. Tente novamente.');\r\n }\r\n}\r\n\r\n"],"mappings":";AAEA,SAAS,mBAAmB;AAE5B,SAAS,gCAAgC;AACzC,SAAS,gBAAgB;AAEzB,eAAsB,YAAY,aAAmD;AACnF,MAAI;AACF,UAAM,aAAa,MAAM,yBAAyB;AAClD,WAAO,MAAM,YAAY,MAAM,aAAa,UAAU;AAAA,EACxD,SAAS,OAAO;AACd,QAAI,iBAAiB,UAAU;AAC7B,YAAM,IAAI,MAAM,MAAM,OAAO;AAAA,IAC/B;AACA,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
import { authService } from '../services/auth.service';
|
|
4
4
|
import { LoginRequest, LoginResponse } from '../schema';
|
|
5
5
|
import { getClientInfoFromRequest } from '../../../infra/utils/client-info';
|
|
6
|
+
import { ApiError } from '../../../infra/api/types';
|
|
6
7
|
|
|
7
8
|
export async function loginAction(credentials: LoginRequest): Promise<LoginResponse> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
try {
|
|
10
|
+
const clientInfo = await getClientInfoFromRequest();
|
|
11
|
+
return await authService.login(credentials, clientInfo);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
if (error instanceof ApiError) {
|
|
14
|
+
throw new Error(error.message); // Error puro propaga a mensagem
|
|
15
|
+
}
|
|
16
|
+
throw new Error('Erro ao realizar login. Tente novamente.');
|
|
17
|
+
}
|
|
11
18
|
}
|
|
19
|
+
|