Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47cde9caa5 |
@@ -1,36 +0,0 @@
|
||||
### MODULES
|
||||
|
||||
-api
|
||||
- register +
|
||||
- logut +
|
||||
- login +
|
||||
- check-demo-status
|
||||
- check-token-balance
|
||||
- content
|
||||
- dismiss-notification
|
||||
- download
|
||||
- download-certificate
|
||||
- download-pdf-tracked
|
||||
- export-report
|
||||
- forgor-password
|
||||
- generate-certificate
|
||||
- get-pdf-tracking-token
|
||||
- get-user-data
|
||||
- login ?
|
||||
- logaut ?
|
||||
- notifications-api
|
||||
- preview-certificate
|
||||
- register
|
||||
- reports
|
||||
- reset-password
|
||||
- token-manager
|
||||
- track-pdf-open
|
||||
- upload
|
||||
- validate-upload
|
||||
- verify-video
|
||||
- violations
|
||||
|
||||
infra
|
||||
-grafana/prom +
|
||||
- ci/cd
|
||||
|
||||
@@ -16,7 +16,6 @@ services:
|
||||
|
||||
app:
|
||||
image: popovtsev/ncp
|
||||
# build: .
|
||||
container_name: no_copy_app
|
||||
environment:
|
||||
POSTGRES_DB: no_copy_
|
||||
|
||||
@@ -3,7 +3,10 @@ package ru.soune.no_copy.controller;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.soune.no_copy.dto.AuthResponse;
|
||||
import ru.soune.no_copy.dto.LoginRequest;
|
||||
import ru.soune.no_copy.dto.LoginResponse;
|
||||
@@ -11,8 +14,6 @@ import ru.soune.no_copy.dto.RegisterRequest;
|
||||
import ru.soune.no_copy.entity.AuthToken;
|
||||
import ru.soune.no_copy.service.AuthService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/auth")
|
||||
@RequiredArgsConstructor
|
||||
@@ -35,13 +36,4 @@ public class AuthController {
|
||||
return ResponseEntity.ok(new LoginResponse(true, login.getUser().getEmail(),
|
||||
login.getToken(),login.getExpiresAt().toString()));
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
public ResponseEntity<?> logout(@RequestHeader("Authorization") String tokenHeader) {
|
||||
String token = tokenHeader.replace("Bearer ", "");
|
||||
|
||||
authService.logout(token);
|
||||
|
||||
return ResponseEntity.ok(Map.of("success", true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package ru.soune.no_copy.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.soune.no_copy.dto.UserDTO;
|
||||
import ru.soune.no_copy.repository.UserRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/user")
|
||||
@RequiredArgsConstructor
|
||||
public class UserController {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<UserDTO>> getAllUsers() {
|
||||
List<UserDTO> allUsers = userRepository.findAll().stream()
|
||||
.map(u -> new UserDTO(u.getFirstName(), u.getEmail(), u.getIsActive()))
|
||||
.toList();
|
||||
|
||||
return ResponseEntity.ok(allUsers);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package ru.soune.no_copy.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class UserDTO {
|
||||
private String fullName;
|
||||
private String email;
|
||||
private boolean isActive;
|
||||
}
|
||||
@@ -53,6 +53,6 @@ public class User {
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "is_active")
|
||||
private Boolean isActive = true;
|
||||
private Boolean isActive;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,5 +10,4 @@ import java.util.Optional;
|
||||
@Repository
|
||||
public interface AuthTokenRepository extends JpaRepository<AuthToken, Long> {
|
||||
Optional<AuthToken> findByTokenAndExpiresAtAfter(String token, LocalDate expiresAtAfter);
|
||||
Optional<AuthToken> findByToken(String token);
|
||||
}
|
||||
|
||||
@@ -78,10 +78,6 @@ public class AuthService {
|
||||
return authTokenRepository.save(authToken);
|
||||
}
|
||||
|
||||
public void logout(String token) {
|
||||
authTokenRepository.findByToken(token)
|
||||
.ifPresent(authTokenRepository::delete);
|
||||
}
|
||||
|
||||
private String generateAuthToken() {
|
||||
byte[] bytes = new byte[32];
|
||||
|
||||
Reference in New Issue
Block a user