Use generic password instead of internet credentials

This commit is contained in:
Arnaud Vergnet 2020-10-07 10:53:31 +02:00
parent 7672dd109d
commit 00ed963503

View file

@ -34,7 +34,6 @@ import {apiRequest, ERROR_TYPE} from '../utils/WebData';
* 500 : SERVER_ERROR -> pb coté serveur * 500 : SERVER_ERROR -> pb coté serveur
*/ */
const SERVER_NAME = 'amicale-insat.fr';
const AUTH_PATH = 'password'; const AUTH_PATH = 'password';
export default class ConnectionManager { export default class ConnectionManager {
@ -78,7 +77,7 @@ export default class ConnectionManager {
if (token != null) { if (token != null) {
resolve(); resolve();
} else { } else {
Keychain.getInternetCredentials(SERVER_NAME) Keychain.getGenericPassword()
.then((data: Keychain.UserCredentials | false) => { .then((data: Keychain.UserCredentials | false) => {
if (data && data.password != null) { if (data && data.password != null) {
this.token = data.password; this.token = data.password;
@ -108,7 +107,7 @@ export default class ConnectionManager {
*/ */
async saveLogin(email: string, token: string): Promise<void> { async saveLogin(email: string, token: string): Promise<void> {
return new Promise((resolve: () => void, reject: () => void) => { return new Promise((resolve: () => void, reject: () => void) => {
Keychain.setInternetCredentials(SERVER_NAME, 'token', token) Keychain.setGenericPassword('token', token)
.then(() => { .then(() => {
this.token = token; this.token = token;
resolve(); resolve();
@ -124,7 +123,7 @@ export default class ConnectionManager {
*/ */
async disconnect(): Promise<void> { async disconnect(): Promise<void> {
return new Promise((resolve: () => void, reject: () => void) => { return new Promise((resolve: () => void, reject: () => void) => {
Keychain.resetInternetCredentials(SERVER_NAME) Keychain.resetGenericPassword()
.then(() => { .then(() => {
this.token = null; this.token = null;
resolve(); resolve();