<& /Minimal/Elements/Header, Title => loc('Preferences') &> <& /Elements/ListActions, actions => \@results &>
% unless (RT->Config->Get('WebExternalAuth') and !RT->Config->Get('WebFallbackToInternalAuth')) { <&| /Widgets/TitleBox, title => loc('Change password') &> <&|/l&>New password: <&|/l&>Confirm: <& /Elements/Submit, Label => loc('Save Changes') &>
% } %#
% require RT::Crypt::GnuPG; % my %res = RT::Crypt::GnuPG::GetKeyInfo( $UserObj->EmailAddress(), 'Public' ); % if($res{'exit_code'} || !keys %{ $res{'info'} } ){ <&|/Widgets/TitleBox, title => loc( 'Upload PGP Public Key' ) &> <& /Elements/Submit, Name => 'Upload', Label => loc('Upload Key') &> % } else { <&|/Widgets/TitleBox, title => loc( 'Purge Key' ) &> <&|/l&>Key: <& /Elements/GnuPG/SelectKeyForEncryption, EmailAddress => $UserObj->EmailAddress &> <& /Elements/Submit, Name => 'PurgeKey', Label => loc('Purge Key') &> % }
<%INIT> my @results; my $UserObj = $session{'CurrentUser'}->UserObj; if($PurgeKey){ require RT::IR::Federation; RT::IR::Federation::PurgeKey($PreferredKey); push(@results, 'Key '.$PreferredKey.' Purged'); } if($UploadKey){ unless($UploadKey =~ /^\-\-\-\-\-BEGIN PGP PUBLIC KEY BLOCK\-\-\-\-\-/ && $UploadKey =~ /\-\-\-\-\-END PGP PUBLIC KEY BLOCK\-\-\-\-\-/){ push(@results,'Public Keys Only!'); } else { my %opt = RT->Config->Get('GnuPGOptions'); my $g = GnuPG::Interface->new(); $g->options->hash_init( RT::Crypt::GnuPG::_PrepareGnuPGOptions( %opt ), armor => 1, meta_interactive => 0, ); my ($input,$output) = (IO::Handle->new(), IO::Handle->new()); my $handles = GnuPG::Handles->new(stdin => $input, stdout => $output); my $pid = $g->import_keys(handles => $handles); print $input $UploadKey; close($input); push(@results, loc('Key successfully Uploaded')."\n$UploadKey"); } } if($NewPass1) { if ($NewPass1 ne $NewPass2) { push (@results, "Passwords did not match."); } else { my ($val, $msg)=$session{'CurrentUser'}->UserObj->SetPassword($NewPass1); push (@results, "Password: ".$msg); } } if($Signature) { $Signature =~ s/(\r\n|\r)/\n/g; if ($Signature ne $session{'CurrentUser'}->UserObj->Signature) { my ($val, $msg)=$session{'CurrentUser'}->UserObj->SetSignature($Signature); push (@results, "Signature: ".$msg); } } #A hack to make sure that session gets rewritten. $session{'i'}++; <%ARGS> $Update => 0, $GenKey => 0, $UploadKey => undef, $Key => undef, $Comment => undef, $PreferredKey => undef, $PurgeKey => undef, $Signature => undef $NewPass1 => undef $NewPass2 => undef