mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
clear device token on logout
This commit is contained in:
parent
a13f1885fb
commit
b40008517b
@ -3,8 +3,6 @@ import { registerRootComponent } from 'expo';
|
|||||||
import App from './App';
|
import App from './App';
|
||||||
import messaging from '@react-native-firebase/messaging';
|
import messaging from '@react-native-firebase/messaging';
|
||||||
|
|
||||||
messaging().requestPermission().then(status => {})
|
|
||||||
|
|
||||||
messaging().registerDeviceForRemoteMessages().then(() => {});
|
messaging().registerDeviceForRemoteMessages().then(() => {});
|
||||||
|
|
||||||
messaging().setBackgroundMessageHandler(async remoteMessage => {});
|
messaging().setBackgroundMessageHandler(async remoteMessage => {});
|
||||||
|
@ -434,6 +434,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||||
|
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Databag/Databag.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Databag/Databag.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 30;
|
CURRENT_PROJECT_VERSION = 30;
|
||||||
@ -463,6 +464,7 @@
|
|||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
VALIDATE_WORKSPACE = YES;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
@ -471,8 +473,10 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
baseConfigurationReference = 7A4D352CD337FB3A3BF06240 /* Pods-Databag.release.xcconfig */;
|
baseConfigurationReference = 7A4D352CD337FB3A3BF06240 /* Pods-Databag.release.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
ARCHS = "$(ARCHS_STANDARD)";
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||||
|
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Databag/Databag.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Databag/Databag.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 30;
|
CURRENT_PROJECT_VERSION = 30;
|
||||||
@ -496,6 +500,7 @@
|
|||||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
VALIDATE_WORKSPACE = YES;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
|
@ -669,7 +669,7 @@ SPEC CHECKSUMS:
|
|||||||
FirebaseInstallations: 99d24bac0243cf8b0e96cf5426340d211f0bcc80
|
FirebaseInstallations: 99d24bac0243cf8b0e96cf5426340d211f0bcc80
|
||||||
FirebaseMessaging: 4487bbff9b9b927ba1dd3ea40d1ceb58e4ee3cb5
|
FirebaseMessaging: 4487bbff9b9b927ba1dd3ea40d1ceb58e4ee3cb5
|
||||||
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
|
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
|
||||||
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
|
glog: 3d02b25ca00c2d456734d0bcff864cbc62f6ae1a
|
||||||
GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
|
GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
|
||||||
GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7
|
GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7
|
||||||
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
|
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
|
||||||
|
7
app/mobile/src/api/clearLogin.js
Normal file
7
app/mobile/src/api/clearLogin.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||||
|
import base64 from 'react-native-base64'
|
||||||
|
|
||||||
|
export async function clearLogin(server, token) {
|
||||||
|
let logout = await fetchWithTimeout(`https://${server}/account/apps?agent=${token}`, { method: 'DELETE' })
|
||||||
|
checkResponse(logout)
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useState, useRef, useContext } from 'react';
|
import { useEffect, useState, useRef, useContext } from 'react';
|
||||||
import { getAvailable } from 'api/getAvailable';
|
import { getAvailable } from 'api/getAvailable';
|
||||||
import { setLogin } from 'api/setLogin';
|
import { setLogin } from 'api/setLogin';
|
||||||
|
import { clearLogin } from 'api/clearLogin';
|
||||||
import { removeProfile } from 'api/removeProfile';
|
import { removeProfile } from 'api/removeProfile';
|
||||||
import { setAccountAccess } from 'api/setAccountAccess';
|
import { setAccountAccess } from 'api/setAccountAccess';
|
||||||
import { addAccount } from 'api/addAccount';
|
import { addAccount } from 'api/addAccount';
|
||||||
@ -87,10 +88,22 @@ export function useAppContext() {
|
|||||||
login: async (username, password) => {
|
login: async (username, password) => {
|
||||||
const acc = username.split('@');
|
const acc = username.split('@');
|
||||||
const access = await setLogin(acc[0], acc[1], password, getApplicationName(), getVersion(), getDeviceId(), state.deviceToken, ['contact', 'channel'])
|
const access = await setLogin(acc[0], acc[1], password, getApplicationName(), getVersion(), getDeviceId(), state.deviceToken, ['contact', 'channel'])
|
||||||
|
if (access.pushSupported) {
|
||||||
|
messaging().requestPermission().then(status => {})
|
||||||
|
}
|
||||||
await store.actions.setSession({ ...access, server: acc[1]});
|
await store.actions.setSession({ ...access, server: acc[1]});
|
||||||
await setSession({ ...access, server: acc[1] });
|
await setSession({ ...access, server: acc[1] });
|
||||||
},
|
},
|
||||||
logout: async () => {
|
logout: async () => {
|
||||||
|
try {
|
||||||
|
await messaging().deleteToken();
|
||||||
|
const token = await messaging().getToken();
|
||||||
|
updateState({ deviceToken: token });
|
||||||
|
await clearLogin(state.server, state.appToken);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
await clearSession();
|
await clearSession();
|
||||||
await store.actions.clearSession();
|
await store.actions.clearSession();
|
||||||
},
|
},
|
||||||
|
@ -47,8 +47,8 @@ export function useProfile() {
|
|||||||
}, [app]);
|
}, [app]);
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
logout: () => {
|
logout: async () => {
|
||||||
app.actions.logout();
|
await app.actions.logout();
|
||||||
navigate('/');
|
navigate('/');
|
||||||
},
|
},
|
||||||
remove: async () => {
|
remove: async () => {
|
||||||
|
@ -3507,6 +3507,7 @@ components:
|
|||||||
- guid
|
- guid
|
||||||
- appToken
|
- appToken
|
||||||
- created
|
- created
|
||||||
|
- pushSupported
|
||||||
properties:
|
properties:
|
||||||
guid:
|
guid:
|
||||||
type: string
|
type: string
|
||||||
@ -3515,6 +3516,8 @@ components:
|
|||||||
created:
|
created:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
pushSupported:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
Revision:
|
Revision:
|
||||||
type: object
|
type: object
|
||||||
|
Loading…
Reference in New Issue
Block a user