feat: getDefaultPublicKey and firstConnect with key
* getDefaultPublicKey make sure that you will get a public key, if it doesn't exist, create one * firstConnect with key instead of password
This commit is contained in:
		
							
								
								
									
										17
									
								
								src/home.ts
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/home.ts
									
									
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
import * as vscode from 'vscode';
 | 
			
		||||
import RemoteContainer from './remote-container';
 | 
			
		||||
import {fetch} from './utils'
 | 
			
		||||
import * as utils from './utils'
 | 
			
		||||
 | 
			
		||||
export default class DSHome {
 | 
			
		||||
  private context: vscode.ExtensionContext;
 | 
			
		||||
@@ -23,7 +23,7 @@ export default class DSHome {
 | 
			
		||||
      }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    fetch(url).then(async (content) => {
 | 
			
		||||
    utils.fetch(url).then(async (content) => {
 | 
			
		||||
      panel.webview.html = await this.getWebviewContent(content);
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
@@ -31,7 +31,7 @@ export default class DSHome {
 | 
			
		||||
      async (message) => {
 | 
			
		||||
        switch (message.command) {
 | 
			
		||||
          case 'firstOpenRemoteFolder':
 | 
			
		||||
            await this.remoteContainer.firstConnect(message.host, message.username, message.password, message.port)
 | 
			
		||||
            await this.remoteContainer.firstConnect(message.host, message.username, message.port)
 | 
			
		||||
            .then((_res) => {
 | 
			
		||||
              if (_res == 'success') {
 | 
			
		||||
                //  only success then open folder
 | 
			
		||||
@@ -64,6 +64,17 @@ export default class DSHome {
 | 
			
		||||
              panel.webview.postMessage({ command: 'setUserToken', data: {ok: false}})
 | 
			
		||||
              break;
 | 
			
		||||
            }
 | 
			
		||||
          case 'getDefaultPublicKey':
 | 
			
		||||
            var defaultPublicKey;
 | 
			
		||||
            if (utils.existDefaultPublicKey()) {
 | 
			
		||||
              defaultPublicKey = utils.getDefaultPublicKey();
 | 
			
		||||
            } else {
 | 
			
		||||
              // if default public key doesn't exist, create it
 | 
			
		||||
              utils.createSSHKey();
 | 
			
		||||
              defaultPublicKey = utils.getDefaultPublicKey();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            panel.webview.postMessage({ command: 'getDefaultPublicKey', data: {defaultPublicKey: defaultPublicKey}})
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      undefined,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user