mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-04 05:53:21 +00:00 
			
		
		
		
	This PR helps to validate custom/self-signed certificates for servers by saving the certificate file in certificates folder in user's appData folder. We now use this certificate with the request while validating the server when adding the organization. This validation of certificate is done by the request module itself. Fixes: #126.
		
			
				
	
	
		
			65 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
'use strict';
 | 
						|
 | 
						|
const BaseSection = require(__dirname + '/base-section.js');
 | 
						|
const DomainUtil = require(__dirname + '/../../utils/domain-util.js');
 | 
						|
const ServerInfoForm = require(__dirname + '/server-info-form.js');
 | 
						|
const AddCertificate = require(__dirname + '/add-certificate.js');
 | 
						|
 | 
						|
class ConnectedOrgSection extends BaseSection {
 | 
						|
	constructor(props) {
 | 
						|
		super();
 | 
						|
		this.props = props;
 | 
						|
	}
 | 
						|
 | 
						|
	template() {
 | 
						|
		return `
 | 
						|
			<div class="settings-pane" id="server-settings-pane">
 | 
						|
				<div class="page-title">Connected organizations</div>
 | 
						|
				<div class="title" id="existing-servers">All the connected orgnizations will appear here.</div>
 | 
						|
				<div id="server-info-container"></div>
 | 
						|
 | 
						|
				<div class="page-title">Add Custom Certificates</div>
 | 
						|
				<div id="add-certificate-container"></div>
 | 
						|
			</div>
 | 
						|
		`;
 | 
						|
	}
 | 
						|
 | 
						|
	init() {
 | 
						|
		this.initServers();
 | 
						|
	}
 | 
						|
 | 
						|
	initServers() {
 | 
						|
		this.props.$root.innerHTML = '';
 | 
						|
 | 
						|
		const servers = DomainUtil.getDomains();
 | 
						|
		this.props.$root.innerHTML = this.template();
 | 
						|
		this.$serverInfoContainer = document.getElementById('server-info-container');
 | 
						|
		this.$existingServers = document.getElementById('existing-servers');
 | 
						|
 | 
						|
		const noServerText = 'All the connected orgnizations will appear here';
 | 
						|
		// Show noServerText if no servers are there otherwise hide it
 | 
						|
		this.$existingServers.innerHTML = servers.length === 0 ? noServerText : '';
 | 
						|
 | 
						|
		for (let i = 0; i < servers.length; i++) {
 | 
						|
			new ServerInfoForm({
 | 
						|
				$root: this.$serverInfoContainer,
 | 
						|
				server: servers[i],
 | 
						|
				index: i,
 | 
						|
				onChange: this.reloadApp
 | 
						|
			}).init();
 | 
						|
		}
 | 
						|
 | 
						|
		this.$addCertificateContainer = document.getElementById('add-certificate-container');
 | 
						|
		this.initAddCertificate();
 | 
						|
	}
 | 
						|
 | 
						|
	initAddCertificate() {
 | 
						|
		new AddCertificate({
 | 
						|
			$root: this.$addCertificateContainer
 | 
						|
		}).init();
 | 
						|
	}
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
module.exports = ConnectedOrgSection;
 |