mg-library 1.0.510 → 1.0.511
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.
- package/login.js +34 -0
- package/package.json +1 -1
package/login.js
CHANGED
@@ -2,6 +2,36 @@ import * as mgFunctionsLib from './functions.js';
|
|
2
2
|
import * as mgConstantsLib from './constants.js';
|
3
3
|
import axios from 'axios';
|
4
4
|
|
5
|
+
/* export function onPressLogin(dispatch, actions, app, apiUrl, language, data) {
|
6
|
+
try {
|
7
|
+
if (validateForm(data, language)) {
|
8
|
+
let requestData = {
|
9
|
+
app: app,
|
10
|
+
userName: data.userName.toLowerCase(),
|
11
|
+
password: data.password,
|
12
|
+
language: mgConstantsLib.LANGUAGE_SPANISH
|
13
|
+
}
|
14
|
+
dispatch(actions.apiRequest());
|
15
|
+
axios.post(apiUrl + '/Login', requestData, mgFunctionsLib.getRequestHeader())
|
16
|
+
.then(response => {
|
17
|
+
let appSession = response.data;
|
18
|
+
dispatch(actions.login(appSession));
|
19
|
+
mgFunctionsLib.writeToLocalStorage(mgConstantsLib.ACCESS_TOKEN, appSession.accessToken);
|
20
|
+
dispatch(actions.apiSuccess());
|
21
|
+
})
|
22
|
+
.catch(error => {
|
23
|
+
dispatch(actions.apiError());
|
24
|
+
let msg = '';
|
25
|
+
if(error.message!=undefined)
|
26
|
+
msg = ' |>| ' + error.message;
|
27
|
+
mgFunctionsLib.showToastError(mgFunctionsLib.i18nMessage('credentialsInvalid', language) + msg);
|
28
|
+
})
|
29
|
+
}
|
30
|
+
} catch (error) {
|
31
|
+
mgFunctionsLib.showToastError(error);
|
32
|
+
}
|
33
|
+
} */
|
34
|
+
|
5
35
|
export function onPressLogin(dispatch, actions, app, apiUrl, language, data) {
|
6
36
|
try {
|
7
37
|
if (validateForm(data, language)) {
|
@@ -21,6 +51,10 @@ export function onPressLogin(dispatch, actions, app, apiUrl, language, data) {
|
|
21
51
|
})
|
22
52
|
.catch(error => {
|
23
53
|
dispatch(actions.apiError());
|
54
|
+
|
55
|
+
console.log('ERROR');
|
56
|
+
console.log(error.response.data);
|
57
|
+
|
24
58
|
let msg = '';
|
25
59
|
if(error.message!=undefined)
|
26
60
|
msg = ' |>| ' + error.message;
|