* Handle biometric authentication * jailbreak/root detection and biometric small fixes * remove server from initializeSecurityManager and fix loginEntry * Add screen capture prevention and other small fixes * added unit tests to SecurityManager * added shielded nativeID to protect views * use MobilePreventScreenCapture instead of MobileAllowScreenshots in config type definition * Apply Swizzle for screen capture on iOS * Apply patch to bottom sheet to prevent screen captures * fix ios sendReply * Fix SDWebImage swizzle to use the correct session * Fix potential crash on Android when using hardware keyboard * rename patch for network library to remove warning * add temp emm reference * fix initializeSecurityManager tests * fix translations * use siteName for jailbreak detection when connecting to a new server * fix i18n typo * do not query the entire config from the db only the required fields * migrate manage_apps to use defineMessages * use TestHelper.wait in tests * use defineMessages for security manager * fix missing else statement for gm_to_channel * created a TestHelper function to mockQuery and replace as jest.Mock with jest.mocked * fix unit tests * fix unit tests (again) and include setting the test environment to UTC * Fix keyboard disappearing on iOS * update react-native-emm
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {fetchConfigAndLicense} from '@actions/remote/systems';
|
|
import DatabaseManager from '@database/manager';
|
|
import {getServerCredentials} from '@init/credentials';
|
|
import PerformanceMetricsManager from '@managers/performance_metrics_manager';
|
|
import SecurityManager from '@managers/security_manager';
|
|
import WebsocketManager from '@managers/websocket_manager';
|
|
|
|
type AfterLoginArgs = {
|
|
serverUrl: string;
|
|
}
|
|
|
|
export async function loginEntry({serverUrl}: AfterLoginArgs): Promise<{error?: unknown}> {
|
|
const operator = DatabaseManager.serverDatabases[serverUrl]?.operator;
|
|
if (!operator) {
|
|
return {error: `${serverUrl} database not found`};
|
|
}
|
|
|
|
// There are cases where the target may be reset and a performance metric
|
|
// be added after login. This would be done with a wrong value, so we make
|
|
// sure we don't do this by skipping the load metric here.
|
|
PerformanceMetricsManager.skipLoadMetric();
|
|
|
|
// But still we want to log the TTI
|
|
PerformanceMetricsManager.startTimeToInteraction();
|
|
|
|
try {
|
|
const clData = await fetchConfigAndLicense(serverUrl, false);
|
|
if (clData.error) {
|
|
return {error: clData.error};
|
|
}
|
|
|
|
const credentials = await getServerCredentials(serverUrl);
|
|
if (credentials?.token) {
|
|
SecurityManager.addServer(serverUrl, clData.config, true);
|
|
WebsocketManager.createClient(serverUrl, credentials.token);
|
|
await WebsocketManager.initializeClient(serverUrl, 'Login');
|
|
SecurityManager.setActiveServer(serverUrl);
|
|
}
|
|
|
|
return {};
|
|
} catch (error) {
|
|
return {error};
|
|
}
|
|
}
|