Skip to content

Commit

Permalink
button
Browse files Browse the repository at this point in the history
  • Loading branch information
as6325400 committed Oct 26, 2024
1 parent 2d6f4ff commit d9f1830
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
40 changes: 40 additions & 0 deletions webapp/migrations/Version20241026085041.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241026085041 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE executable DROP zipfile');
$this->addSql('ALTER TABLE problem CHANGE multipass_limit multipass_limit INT UNSIGNED DEFAULT NULL COMMENT \'Optional limit on the number of rounds; defaults to 1 for traditional problems, 2 for multi-pass problems if not specified.\'');
$this->addSql('ALTER TABLE user ADD can_change_password TINYINT(1) DEFAULT 0 NOT NULL COMMENT \'Whether the user can change their password\'');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE executable ADD zipfile LONGBLOB DEFAULT NULL COMMENT \'Zip file\'');
$this->addSql('ALTER TABLE user DROP can_change_password');
$this->addSql('ALTER TABLE problem CHANGE multipass_limit multipass_limit INT UNSIGNED DEFAULT NULL COMMENT \'Optional limit on the number of rounds for multi-pass problems; defaults to 2 if not specified.\'');
}

public function isTransactional(): bool
{
return false;
}
}
14 changes: 14 additions & 0 deletions webapp/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ class User extends BaseApiEntity implements
#[Serializer\Groups([ARC::GROUP_NONSTRICT])]
private bool $enabled = true;

#[ORM\Column(options: ['comment' => 'Whether the user can change their password', 'default' => 0])]
#[Serializer\Groups([ARC::GROUP_NONSTRICT])]
private bool $canChangePassword = false;

#[ORM\ManyToOne(inversedBy: 'users')]
#[ORM\JoinColumn(name: 'teamid', referencedColumnName: 'teamid', onDelete: 'SET NULL')]
#[Serializer\Exclude]
Expand Down Expand Up @@ -514,4 +518,14 @@ public function getCalculatedExternalId(): string
{
return $this->getUsername();
}

public function getCanChangePassword(): bool
{
return $this->canChangePassword;
}
public function setCanChangePassword(bool $canChangePassword): self
{
$this->canChangePassword = $canChangePassword;
return $this;
}
}
7 changes: 7 additions & 0 deletions webapp/src/Form/Type/UserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'No' => false,
],
]);
$builder->add('canChangePassword', ChoiceType::class, [
'expanded' => true,
'choices' => [
'Yes' => true,
'No' => false,
],
]);
$builder->add('team', ChoiceType::class, [
'choice_label' => 'effective_name',
'required' => false,
Expand Down
17 changes: 17 additions & 0 deletions webapp/templates/partials/menu_change_password_button.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
<a class="btn btn-info btn-sm me-2" href="{{ path('logout') }}"
{% if confirmLogout is defined %}
onclick="return confirmLogout();"
{% endif %}>
<i class="fas fa-rotate"></i> Change Password
</a>
{% else %}
{% if allow_registration %}
<a class="btn btn-info btn-sm justify-content-center me-2" href="{{ path('register') }}">
<i class="fas fa-user-plus"></i> Register
</a>
{% endif %}
<a class="btn btn-info btn-sm me-2" href="{{ path('login') }}">
<i class="fas fa-sign-in-alt"></i> Login
</a>
{% endif %}
1 change: 1 addition & 0 deletions webapp/templates/team/menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
</div>

{% include 'partials/menu_login_logout_button.html.twig' with {confirmLogout: true} %}
{% include 'partials/menu_change_password_button.html.twig' with {confirmLogout: true} %}

<ul class="navbar-nav">
{% if current_team_contests | length > 1 %}
Expand Down

0 comments on commit d9f1830

Please sign in to comment.