diff --git a/lib/LDV/User.pm b/lib/LDV/User.pm index e57c6ab..d8c11ec 100644 --- a/lib/LDV/User.pm +++ b/lib/LDV/User.pm @@ -75,10 +75,17 @@ sub create { die("$error") if $error; $error = $self->app->ldap->update($user, {mail => $mail}); die("$error") if $error; - $error = $self->app->ldap->chpass($user, $pass); - die("$error") if $error; - # TODO: confirmation email + if ($self->app->{user}->{confirm_register}) { + my $body = $self->render_partial(template => 'email/reg_success', format => 'txt') + my $email = $self->app->email->create($mail, $self->l("Registration"), $body); + $error = $self->app->email->send($to, $email); + die("$error") if $error; + # TODO: generate and store recover code + } else { + $error = $self->app->ldap->chpass($user, $pass); + die("$error") if $error; + } $self->flash({result => "Success! Now you may log in."}); $self->redirect_to('/user/profile'); 1;