forked from vergnet/application-amicale
Removed unused function
This commit is contained in:
parent
d622a2f77a
commit
f9efea288f
1 changed files with 8 additions and 28 deletions
|
@ -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,38 +138,18 @@ 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);
|
})
|
||||||
})
|
.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
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue