Skip to content

Commit

Permalink
Add button to reset the login status of all user with the team role.
Browse files Browse the repository at this point in the history
  • Loading branch information
meisterT committed Oct 22, 2022
1 parent a4499c2 commit 2acb86f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions webapp/src/Controller/Jury/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,25 @@ public function generatePasswordsAction(Request $request): Response
'form' => $form->createView(),
]);
}

/**
* @Route("/reset_login_status", name="jury_reset_login_status")
* @IsGranted("ROLE_ADMIN")
*/
public function resetTeamLoginStatus(Request $request): Response
{
/** @var Role $teamRole */
$teamRole = $this->em->getRepository(Role::class)->findOneBy(['dj_role' => 'team']);
$count = 0;
foreach ($teamRole->getUsers() as $user) {
/** @var User $user */
$user->setFirstLogin(null);
$user->setLastLogin(null);
$user->setLastIpAddress(null);
$count++;
}
$this->em->flush();
$this->addFlash('success', 'Reset login status all ' . $count . ' users with the team role.');
return $this->redirect($this->generateUrl('jury_users'));
}
}
2 changes: 1 addition & 1 deletion webapp/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public function getFirstLoginAsDateTime(): ?DateTime
return $this->getFirstLogin() ? new DateTime(Utils::absTime($this->getFirstLogin())) : null;
}

public function setLastIpAddress(string $lastIpAddress): User
public function setLastIpAddress(?string $lastIpAddress): User
{
$this->last_ip_address = $lastIpAddress;
return $this;
Expand Down
1 change: 1 addition & 0 deletions webapp/templates/jury/users.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
{% if is_granted('ROLE_ADMIN') %}
<p>
{{ button(path('jury_user_add'), 'Add new user', 'primary', 'plus') }}
{{ button(path('jury_reset_login_status'), 'Reset login status of all team users', 'secondary', 'refresh') }}
</p>
{% endif %}
{% endblock %}

0 comments on commit 2acb86f

Please sign in to comment.