Code Monkey home page Code Monkey logo

Comments (7)

yuya-oc avatar yuya-oc commented on July 2, 2024

Maybe possible, the API has been just tested at dca9b62.
But Electron doesn't support any input dialog such as window.prompt, so the app has to implement on its own.

from desktop.

mgielda avatar mgielda commented on July 2, 2024

Let me jump in here, I had solved the problem in a not-so-graceful but effective way once for a different app, perhaps this experience can come in handy (did spend some hours testing various libraries which refused to work before coming up with this):

var app = require('app');
var BrowserWindow = require('browser-window');

var prompt = require('sync-prompt').prompt;

var name = prompt('Username: ');
var password = prompt.hidden('Password: ');

app.on('login', function (event, webContents, request, authInfo, callback) {
  event.preventDefault();
  console.log("Replacing default auth behaviour.");
  callback(name, password);
});

from desktop.

yuya-oc avatar yuya-oc commented on July 2, 2024

Thank you for feedback. I think It will work, however users have to use command-line and keep it opened.

Note: callback() can be called asynchronously, so sync-prompt might not be necessary. Then, sync-prompt is a native module, so it's a little hard to compile release version. (On my environment, Windows 10 + Node 4.2.2 + VS2015 Update1, I could not compile sync-prompt.)

from desktop.

yuya-oc avatar yuya-oc commented on July 2, 2024

readline-sync might be nice for @mgielda's example. It looks JavaScript.

from desktop.

mgielda avatar mgielda commented on July 2, 2024

@yuya-oc indeed it works (sorry it took some time to answer) - so I agree, the updated snippet is:

var readlineSync = require('readline-sync'); //tested on readline-sync 1.4.1

var username = readlineSync.question('Username: ');
var password = readlineSync.question('Password: ', {
  hideEchoBack: true // The typed text on screen is hidden by `*` (default). 
});

app.on('login', function (event, webContents, request, authInfo, callback) {
  event.preventDefault();
  console.log("Replacing default auth behaviour.");
  callback(username, password);
});

How should we proceed with that? There needs to be some config option for this I suppose. I agree that doing a graphical version later is a good idea but for now this would be good enough. Should we perhaps propose a pull request?

from desktop.

yuya-oc avatar yuya-oc commented on July 2, 2024

Closed by the commit message. This should not be closed yet.

from desktop.

mgielda avatar mgielda commented on July 2, 2024

Sorry! You are right of course. Habit from my own projects.

from desktop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.