summaryrefslogtreecommitdiffstats
path: root/perl-install/install_steps_interactive.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/install_steps_interactive.pm')
-rw-r--r--perl-install/install_steps_interactive.pm35
1 files changed, 19 insertions, 16 deletions
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index a4571ec7b..dee757d8b 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -417,26 +417,29 @@ sub addUser($) {
my ($o) = @_;
$o->{user} ||= {};
$o->{user}{password2} ||= $o->{user}{password};
- my $sup = $o->{user};
+ my $u = $o->{user};
my @fields = qw(name password password2 realname);
my @shells = install_any::shells($o);
- $o->ask_from_entries_ref(_("Add user"),
- _("Enter a user"),
- [_("User name"), _("Password"), _("Password (again)"), _("Real name"), _("Shell"),],
- [(map { \$sup->{$_}} @fields),
- {val => \$sup->{shell}, list => \@shells, not_edit => !$::expert},
- ],
- complete => sub {
- $sup->{password} eq $sup->{password2} or $o->ask_warn('', [ _("You must enter the same password"), _("Please try again") ]), return (1,2);
- (length $sup->{password} < 6) and $o->ask_warn('', _("This password is too simple")), return (1,1);
- $sup->{name} or $o->ask_warn('', _("Please give a user name")), return (1,0);
- $sup->{name} =~ /^[a-z0-9_-]+$/ or $o->ask_warn('', _("The user name must contain only lower cased letters, numbers, `-' and `_'")), return (1,0);
- return 0;
- }
-
- );
+ $o->ask_from_entries_ref(
+ _("Add user"),
+ _("Enter a user"),
+ [ _("Real name"), _("User name"), _("Password"), _("Password (again)"), _("Shell") ],
+ [ (map { \$u->{$_}} @fields),
+ {val => \$u->{shell}, list => \@shells, not_edit => !$::expert},
+ ],
+ focus_out => sub {
+ ($u->{name}) = $u->{realname} =~ /\U(\S+)/ if $_[0] eq 0;
+ },
+ complete => sub {
+ $u->{password} eq $u->{password2} or $o->ask_warn('', [ _("You must enter the same password"), _("Please try again") ]), return (1,2);
+ (length $u->{password} < 6) and $o->ask_warn('', _("This password is too simple")), return (1,1);
+ $u->{name} or $o->ask_warn('', _("Please give a user name")), return (1,0);
+ $u->{name} =~ /^[a-z0-9_-]+$/ or $o->ask_warn('', _("The user name must contain only lower cased letters, numbers, `-' and `_'")), return (1,0);
+ return 0;
+ },
+ );
install_steps::addUser($o);
$o->{user} = {};
goto &addUser if $::expert;