Skip to content
Snippets Groups Projects
Verified Commit 0108fdcd authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Roles bugfix, allow skip migration

parent bed7ac3b
No related branches found
No related tags found
No related merge requests found
Pipeline #6030 passed
...@@ -2,7 +2,7 @@ image: docker:20.10.9 ...@@ -2,7 +2,7 @@ image: docker:20.10.9
variables: variables:
DOCKER_TLS_CERTDIR: "/certs" DOCKER_TLS_CERTDIR: "/certs"
IMAGE_VER: 0.5.0 IMAGE_VER: 0.5.1
services: services:
- docker:20.10.9-dind - docker:20.10.9-dind
......
...@@ -24,19 +24,21 @@ sub startup { ...@@ -24,19 +24,21 @@ sub startup {
# $self->helper( redis => sub { return $redis; } ); # $self->helper( redis => sub { return $redis; } );
# migrace schematu # migrace schematu
my $pg = Mojo::Pg->new if (! $cfg->{skip_migration}) {
->dsn($cfg->{db_dsn}) my $pg = Mojo::Pg->new
->username($cfg->{db_username}) ->dsn($cfg->{db_dsn})
->password($cfg->{db_password}) ->username($cfg->{db_username})
; ->password($cfg->{db_password})
if ($cfg->{test}) { ;
$pg->search_path(['test']); if ($cfg->{test}) {
$pg->db->query('drop schema if exists test cascade'); $pg->search_path(['test']);
$pg->db->query('create schema test'); $pg->db->query('drop schema if exists test cascade');
$pg->db->query('create schema test');
}
$pg->migrations->from_dir($self->home . '/sql');
$pg->migrations->migrate();
$self->helper( pg => sub { return $pg; } );
} }
$pg->migrations->from_dir($self->home . '/sql');
$pg->migrations->migrate();
$self->helper( pg => sub { return $pg; } );
# DB Schema # DB Schema
my $schema = CF2022::Schema->connect({ my $schema = CF2022::Schema->connect({
......
...@@ -45,9 +45,9 @@ sub create ($c ) { ...@@ -45,9 +45,9 @@ sub create ($c ) {
); );
@products = grep { $_->{id} !~ MAIN_PRODUCTS } @products; @products = grep { $_->{id} !~ MAIN_PRODUCTS } @products;
push @products, { @products = ({
id => $c->config->{'pretix_product_' . $group->{role}} id => $c->config->{'pretix_product_' . $group->{role}}
}; }, @products);
if ( $group->{role} eq 'member' ) { if ( $group->{role} eq 'member' ) {
$args->{email} = $claims->{preferred_username} $args->{email} = $claims->{preferred_username}
......
...@@ -80,12 +80,14 @@ sub register ( $class, $self, $conf) { ...@@ -80,12 +80,14 @@ sub register ( $class, $self, $conf) {
GROUP: GROUP:
foreach my $group ( sort @{ $claims->{groups} } ) { foreach my $group ( sort @{ $claims->{groups} } ) {
if ( $group =~ REGIONS ) { if ( $group =~ REGIONS ) {
my $role = ( $2 eq 'f') ? 'member':'regp';
my $region = $c->oauth_groups->{ $group }; my $region = $c->oauth_groups->{ $group };
$region =~ s/^KS\s+//i; $region =~ s/^KS\s+//i;
return { return {
region => $region, region => $region,
role => ( $2 eq 'f') ? 'member':'regp', role => $role,
}; };
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment