Skip to content

Commit

Permalink
feat: add a validation process to new org creation (#7453)
Browse files Browse the repository at this point in the history
As a new user subscribe, telling he is from a company, if it's the first for that company, we currently create a new org and attach the user to it.
As there is a lot of potential fake data, we would like a "validation" round.

fixes: #7350

Also adds off_org_id and off_user_id to link to CRM in the future.

Also:
* test: added integration test create_pro_user.t
* test: Wait all server parts to be ready
* test: add mail logging and mail comparison
* fix: add default translations for off_org_id and off_user_id
  • Loading branch information
alexgarel authored Nov 15, 2022
1 parent 44d5f83 commit 6cf2d77
Show file tree
Hide file tree
Showing 21 changed files with 1,109 additions and 166 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ integration_test:
${DOCKER_COMPOSE_TEST} stop
@echo "🥫 integration tests success"

# stop all tests dockers
test-stop:
@echo "🥫 Stopping test dockers"
${DOCKER_COMPOSE_TEST} stop

# usage: make test-unit test=test-name.t
test-unit: guard-test
@echo "🥫 Running test: 'tests/unit/${test}' …"
Expand Down
9 changes: 9 additions & 0 deletions cgi/org.pl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
push(
@admin_fields,
(
"valid_org",
"enable_manual_export_to_public_platform",
"activate_automated_daily_export_to_public_platform",
"protect_data",
Expand Down Expand Up @@ -199,6 +200,10 @@
push(
@$admin_fields_ref,
(
{
field => "valid_org",
type => "checkbox",
},
{
field => "enable_manual_export_to_public_platform",
type => "checkbox",
Expand All @@ -211,6 +216,10 @@
field => "protect_data",
type => "checkbox",
},
{
field => "crm_org_id",
label => lang("crm_org_id"),
}
)
);

Expand Down
16 changes: 14 additions & 2 deletions cgi/user.pl
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,15 @@
}
}

if ($type eq 'edit_owner') {
ProductOpener::Users::check_edit_owner($user_ref, \@errors);
# change organization
if ($type eq 'edit_owner' && $admin) {
# only admin and pro moderators can change organization freely
if ($admin or $User{pro_moderator}) {
ProductOpener::Users::check_edit_owner($user_ref, \@errors);
}
else {
display_error_and_exit($Lang{error_no_permission}{$lang}, 403);
}
}
elsif ($type ne 'delete') {
ProductOpener::Users::check_user_form($type, $user_ref, \@errors);
Expand Down Expand Up @@ -283,6 +290,11 @@
field => "org",
label => lang("organization"),
};
push @{$administrator_section_ref->{fields}},
{
field => "crm_user_id",
label => lang("crm_user_id"),
};
foreach my $group (@user_groups) {
push @{$administrator_section_ref->{fields}},
{
Expand Down
1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ on 'test' => sub {
requires 'IO::Capture::Stdout::Extended';
requires 'IO::Capture::Stderr::Extended';
requires 'HTTP::CookieJar::LWP';
requires 'File::Tail';
};

on 'develop' => sub {
Expand Down
Loading

0 comments on commit 6cf2d77

Please sign in to comment.