Skip to content

Commit

Permalink
Test fix for sql generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelayori committed Mar 4, 2024
1 parent 5102408 commit 778a18d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/uniovi/entities/ApiKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ApiKey {
private Long id;

@Column(unique = true)
private String key = UUID.randomUUID().toString();
private String keyToken = UUID.randomUUID().toString();

@OneToOne
private Player player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
import org.springframework.data.repository.CrudRepository;

public interface ApiKeyRepository extends CrudRepository<ApiKey, Long> {
ApiKey findByKey(String key);
ApiKey findByKeyToken(String key);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
public interface RestApiLogRepository extends CrudRepository<RestApiAccessLog, Long> {
List<RestApiAccessLog> findByApiKey(ApiKey apiKey);

@Query("SELECT r FROM RestApiAccessLog r WHERE r.apiKey.user = ?1")
@Query("SELECT r FROM RestApiAccessLog r WHERE r.apiKey.player = ?1")
List<RestApiAccessLog> findByUser(Player user);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public ApiKey createApiKey(Player forPlayer) {

@Override
public ApiKey getApiKey(String apiKey) {
return apiKeyRepository.findByKey(apiKey);
return apiKeyRepository.findByKeyToken(apiKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public List<Player> getUsersByRole(String role) {
public void generateApiKey(Player player) {
ApiKey apiKey = new ApiKey();
Associations.PlayerApiKey.addApiKey(player, apiKey);
System.out.println("Generated API key for " + player.getUsername() + ": " + apiKey.getKey());
System.out.println("Generated API key for " + player.getUsername() + ": " + apiKey.getKeyToken());
playerRepository.save(player);
}
}

0 comments on commit 778a18d

Please sign in to comment.