-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split User and Player class properly to avoid side filter attacks
- Loading branch information
1 parent
0c54fe3
commit bddf852
Showing
13 changed files
with
161 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
package com.faforever.api.ban; | ||
|
||
import com.faforever.api.data.domain.Player; | ||
import com.faforever.api.player.PlayerRepository; | ||
import com.faforever.api.data.domain.User; | ||
import com.faforever.api.user.UserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class BanService { | ||
private final PlayerRepository playerRepository; | ||
private final UserRepository userRepository; | ||
|
||
public BanService(PlayerRepository playerRepository) { | ||
this.playerRepository = playerRepository; | ||
} | ||
|
||
public boolean hasActiveGlobalBan(Player player) { | ||
return player.isGlobalBanned(); | ||
public boolean hasActiveGlobalBan(User user) { | ||
return user.isGlobalBanned(); | ||
} | ||
|
||
public boolean hasActiveGlobalBan(String username) { | ||
return hasActiveGlobalBan(playerRepository.findOneByLogin(username)); | ||
return userRepository.findOneByLogin(username) | ||
.map(this::hasActiveGlobalBan) | ||
.orElse(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.