Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Added password prompt to Console #6646

Closed
wants to merge 8 commits into from
Closed

Added password prompt to Console #6646

wants to merge 8 commits into from

Conversation

richardjh
Copy link
Contributor

SImple prompt that doesn't echo back (or can echo *s). Useful for reading in passwords.
If accepted I'll write up the documentation too.


$this->setPromptText($promptText);
$this->setEcho($echo);
$this->password = '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this $this->password = '' is required as it is a duplicate from line 27

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I'll pull it.

@eddiejaoude
Copy link
Contributor

Nice one. 👍

*/
public function setPromptText($promptText)
{
$this->promptText = $promptText;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would type case this $this->promptText = (string) $promptText;

$char = $this->getConsole()->readChar();

if (PHP_EOL == $char) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded blank line

@eddiejaoude
Copy link
Contributor

The tests seem to pass, but the build gets terminated...No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.

End of output...

...............................................................  63 / 151 ( 41%)
.........S..S....................................SSSSSS........ 126 / 151 ( 83%)
...................SSSSSS
Time: 1.69 seconds, Memory: 12.25Mb
OK, but incomplete or skipped tests!
Tests: 151, Assertions: 333, Skipped: 14.
Generating code coverage report in PHP format ... done
No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.
The build has been terminated

@eddiejaoude
Copy link
Contributor

I was not able to request Travis to rebuild this branch.

I looked at previous commits in this branch and they fail on Travis for the same reason. Tests seem to pass fine, the build gets terminated.

@richardjh Is it worth merging master in again?

@eddiejaoude
Copy link
Contributor

I just checked master build and it is failing for the same reason!

@richardjh
Copy link
Contributor Author

@eddiejaoude, are you saying I need to pull the master branch from zendframework/zf2 into my master branch on richardjh/zf2 again?

@eddiejaoude
Copy link
Contributor

Originally, I was suggesting updating your PR branch (richardjh/zf2:master) with the master of zendframework/zf2:master - but when I checked the source branch (zendframework/zf2:master), it is failing too.

So probably no need, unless there is a manual conflict to resolve before your PR gets merged in - as they are new files, it is unlikely there will be a future conflict.

@asgrim
Copy link
Contributor

asgrim commented Sep 8, 2014

Just a little suggestion, what about making the "mask" character configurable? (e.g. if someone wanted to use # instead of * to mask the password)

@eddiejaoude
Copy link
Contributor

@asgrim good idea 👍

/**
* @var string
*/
protected $promptText = 'Password : ';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 'Password: ' not 'Password : '

Changed the default password prompt, that you can change anyway because @prolic said so.
@richardjh
Copy link
Contributor Author

Not sure if anyone is waiting for this or needs a password prompt, but I have added richardjh\zf2-password to packagist [ https://packagist.org/packages/richardjh/zf2-password ] so you can install the password prompt as a module if you like.

@eddiejaoude
Copy link
Contributor

Thanks @richardjh 👍

@prolic
Copy link
Contributor

prolic commented Dec 4, 2014

nice

@Ocramius Ocramius added this to the 2.4.0 milestone Dec 24, 2014
@Ocramius Ocramius self-assigned this Dec 24, 2014
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2015 ;)

Ocramius added a commit that referenced this pull request Jan 3, 2015
Ocramius added a commit that referenced this pull request Jan 3, 2015
Ocramius added a commit that referenced this pull request Jan 3, 2015
Ocramius added a commit that referenced this pull request Jan 3, 2015
Ocramius added a commit that referenced this pull request Jan 3, 2015
Ocramius added a commit that referenced this pull request Jan 3, 2015
…e password prompt unless strictly specified
Ocramius added a commit that referenced this pull request Jan 3, 2015
Ocramius added a commit that referenced this pull request Jan 3, 2015
@Ocramius
Copy link
Member

Ocramius commented Jan 3, 2015

This was merged into develop at 306c17a

I had to rewrite some bits because the prompt was actually acting really weird when entering multiple rapidly subsequent chars: figured that (for security) the best solution was to clear the line at every keystroke instead.

@Ocramius Ocramius closed this Jan 3, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
…ad of via an actual console adapter (which would hang forever, waiting for input)
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
…ugh the console adapter, not through direct buffer output
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
…ut should be produced by the password prompt unless strictly specified
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-console that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants