From ec811e437c05810cd2e7737da42f8cc80fa9867b Mon Sep 17 00:00:00 2001 From: Kayden Tebau Date: Tue, 18 Oct 2022 10:30:02 -0700 Subject: [PATCH] Fix sshkey --- lib/unix_dog/Controller/Account.pm | 5 +++-- lib/unix_dog/Controller/Register.pm | 4 +++- lib/unix_dog/Util.pm | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/unix_dog/Controller/Account.pm b/lib/unix_dog/Controller/Account.pm index 40fc82a..ff8ad70 100644 --- a/lib/unix_dog/Controller/Account.pm +++ b/lib/unix_dog/Controller/Account.pm @@ -6,6 +6,7 @@ use experimental 'signatures'; use Mojo::Base 'Mojolicious::Controller', -signatures; use Net::LDAPS; use Net::LDAP::Extension::SetPassword; +require unix_dog::Util; sub update_account($self) { my $v = $self->validation; @@ -28,7 +29,7 @@ sub update_account($self) { my $loginShell = $self->param('loginShell'); my $roomNumber = $self->param('roomNumber'); my $telNum = $self->param('telNum'); - my @sshKeys = Util::split_keys($self->param('sshKeys')); + my @sshKeys = unix_dog::Util::split_keys($self->param('sshKeys')); my $curPasswd = $self->param('curPasswd'); my $newPasswd = $self->param('newPasswd'); @@ -76,7 +77,7 @@ sub update_account($self) { loginShell => $loginShell, roomNumber => $roomNumber || [], telephoneNumber => $telNum || [], - sshPublicKey => @sshKeys, + sshPublicKey => \@sshKeys, } ); $mesg->code and die $mesg->error; diff --git a/lib/unix_dog/Controller/Register.pm b/lib/unix_dog/Controller/Register.pm index af80dde..cb88fc7 100644 --- a/lib/unix_dog/Controller/Register.pm +++ b/lib/unix_dog/Controller/Register.pm @@ -11,6 +11,7 @@ use Email::Simple; use Email::Sender::Simple; use Email::Sender::Transport::Sendmail; + sub registration($self) { $self->render('register/registerPage'); } @@ -28,6 +29,7 @@ sub register($self) { my $password = $self->param('password'); my $email = $self->param('email'); my $pubkeys = $self->param('pubkey'); + my @sshKeys = unix_dog::Util::split_keys($pubkeys); my $bio = $self->param('bio'); my $fromIP = $self->tx->remote_address; @@ -99,7 +101,7 @@ sub register($self) { attrs => [ cn => $username, mail => $username . '@unix.dog', - sshPublicKey => Util::split_keys($pubkeys), + sshPublicKey => \@sshKeys, objectClass => [ 'top', 'extensibleObject', diff --git a/lib/unix_dog/Util.pm b/lib/unix_dog/Util.pm index 6088a4b..07d653e 100644 --- a/lib/unix_dog/Util.pm +++ b/lib/unix_dog/Util.pm @@ -1,4 +1,4 @@ -package Util; +package unix_dog::Util; use strict; use warnings FATAL => 'all'; use experimental 'signatures'; @@ -8,5 +8,4 @@ sub split_keys($input) { @out = grep (defined && length, @out); return @out; } - 1;