Removed unused function

This commit is contained in:
Arnaud Vergnet 2020-07-01 23:38:08 +02:00
parent d622a2f77a
commit f9efea288f

View file

@ -1,7 +1,7 @@
// @flow // @flow
import * as Keychain from 'react-native-keychain'; import * as Keychain from 'react-native-keychain';
import {apiRequest, ERROR_TYPE, isResponseValid} from "../utils/WebData"; import {apiRequest, ERROR_TYPE} from "../utils/WebData";
/** /**
* champ: error * champ: error
@ -138,7 +138,6 @@ export default class ConnectionManager {
}; };
apiRequest(AUTH_PATH, 'POST', data) apiRequest(AUTH_PATH, 'POST', data)
.then((response) => { .then((response) => {
if (this.isConnectionResponseValid(response)) {
this.saveLogin(email, response.token) this.saveLogin(email, response.token)
.then(() => { .then(() => {
resolve(true); resolve(true);
@ -146,30 +145,11 @@ export default class ConnectionManager {
.catch(() => { .catch(() => {
reject(ERROR_TYPE.TOKEN_SAVE); reject(ERROR_TYPE.TOKEN_SAVE);
}); });
} else
reject(ERROR_TYPE.SERVER_ERROR);
}) })
.catch((error) => reject(error)); .catch((error) => reject(error));
}); });
} }
/**
* Checks if the API connection response is correctly formatted
*
* @param response
* @returns {boolean}
*/
isConnectionResponseValid(response: { [key: string]: any }) {
let valid = isResponseValid(response);
if (valid && response.error === ERROR_TYPE.SUCCESS)
valid = valid
&& response.data.token !== undefined
&& response.data.token !== ''
&& typeof response.data.token === "string";
return valid;
}
/** /**
* Sends an authenticated request with the login token to the API * Sends an authenticated request with the login token to the API
* *