Fix sshkey

This commit is contained in:
Citlali del Rey 2022-10-18 10:13:00 -07:00
parent 7b59847470
commit 049c0ce221
Signed by: nullobsi
GPG Key ID: 933A1F44222C2634
3 changed files with 15 additions and 6 deletions

View File

@ -28,9 +28,7 @@ sub update_account($self) {
my $loginShell = $self->param('loginShell');
my $roomNumber = $self->param('roomNumber');
my $telNum = $self->param('telNum');
my $sshKeys = $self->param('sshKeys');
$sshKeys =~ s/\r//;
my @sshKeys = split "\n", $sshKeys;
my @sshKeys = Util::split_keys($self->param('sshKeys'));
my $curPasswd = $self->param('curPasswd');
my $newPasswd = $self->param('newPasswd');
@ -44,7 +42,7 @@ sub update_account($self) {
loginShell => $loginShell,
roomNumber => $roomNumber,
telNum => $telNum,
sshKeys => join("\n", @sshKeys),
sshKeys => join("\r\n", @sshKeys),
username => $username,
);

View File

@ -28,7 +28,6 @@ sub register($self) {
my $password = $self->param('password');
my $email = $self->param('email');
my $pubkeys = $self->param('pubkey');
$pubkeys =~ s/\r//;
my $bio = $self->param('bio');
my $fromIP = $self->tx->remote_address;
@ -100,7 +99,7 @@ sub register($self) {
attrs => [
cn => $username,
mail => $username . '@unix.dog',
sshPublicKey => (split "\n", $pubkeys),
sshPublicKey => Util::split_keys($pubkeys),
objectClass => [
'top',
'extensibleObject',

12
lib/unix_dog/Util.pm Normal file
View File

@ -0,0 +1,12 @@
package Util;
use strict;
use warnings FATAL => 'all';
use experimental 'signatures';
sub split_keys($input) {
my @out = split /\R/, $input;
@out = grep (defined && length, @out);
return @out;
}
1;