Skip to content

Commit

Permalink
add logout
Browse files Browse the repository at this point in the history
  • Loading branch information
AlinaMoon123 committed Nov 23, 2024
1 parent cc0f6b2 commit 0bdfcbe
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 66 deletions.
32 changes: 0 additions & 32 deletions lake-catalog/Dockerfile

This file was deleted.

28 changes: 0 additions & 28 deletions lake-catalog/docker-compose.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,12 @@ public String performRegister(String username, String email, String password, St
return "redirect:/register?error=password_mismatch";
}
}

// Выход из профиля
@GetMapping("/logout")
public String logout(HttpSession session) {
session.invalidate(); // Уничтожение текущей сессии
return "redirect:/"; // Перенаправление на главную страницу после выхода
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import jakarta.servlet.http.HttpSession;

import java.net.URI;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Locale;

@Controller
@RequestMapping("/users")
Expand All @@ -46,6 +48,9 @@ public String getUserProfile(@PathVariable Long userId, Model model) {
if (userOptional.isPresent()) {
User user = userOptional.get();
model.addAttribute("user", user);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy", Locale.forLanguageTag("ru"));
String formattedDate = user.getCreationDate().format(formatter);
model.addAttribute("formattedDate", formattedDate);

//Lake lakePage = lakeService.getLakePageByUserId(userId); // Например, метод для получения lakePage
//model.addAttribute("lakePage", lakePage); // Передаем в шаблон
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.Date;
import java.util.Optional;

Expand All @@ -28,6 +29,7 @@ public void registerUser(String nickname, String email, String password) {
user.setEmail(email);
user.setNickname(nickname);
user.setPassword(password);
user.setCreationDate(LocalDate.now());
userRepository.save(user);
//setCurrentUser(userService.findUserByEmail(email).get());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
const backButton = document.getElementById("back-button");
backButton.addEventListener("click", () => {
window.location.href = '/main';
});

const logoutButton = document.getElementById("logout-button");
logoutButton.addEventListener("click", () => {
window.location.href = '/logout';
});

document.addEventListener('DOMContentLoaded', () => {
const tabButtons = document.querySelectorAll('.tab-button');
const tabContents = document.querySelectorAll('.tab-content');
Expand Down
Binary file not shown.
Binary file not shown.
12 changes: 6 additions & 6 deletions lake-catalog/src/main/resources/templates/profile/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ <h1>Профиль</h1>
</header>

<div class="profile-info">
<img src="../assets/avatar.jpg" alt="Фото пользователя" class="profile-photo">
<img src="/assets/avatar.jpg" alt="Фото пользователя" class="profile-photo">
<div class="user-details">
<!-- Поля для отображения имени и email -->
<div id="name-field">
<h2 id="user-name">Имя пользователя</h2>
<h2 id="user-name" th:text="${user.nickname}"></h2>
</div>
<div id="email-field">
<p id="user-email">Email пользователя</p>
<button id="edit-profile" class="icon-button"><img src="../assets/edit.png" alt="Редактировать" class="icon"></button>
<p id="user-email" th:text="${user.email}"> </p>
<button id="edit-profile" class="icon-button"><img src="/assets/edit.png" alt="Редактировать" class="icon"></button>
</div>

<!-- Поля ввода (скрытые по умолчанию) -->
Expand All @@ -38,7 +38,7 @@ <h2 id="user-name">Имя пользователя</h2>
</div>

<div class="profile-dates">
<p>Дата создания: 01.01.2001</p>
<p> Дата создания: <span th:text="${formattedDate}"> </span></p>
<p>Дата редактирования: 01.01.2001</p>
</div>

Expand Down Expand Up @@ -73,7 +73,7 @@ <h2 id="user-name">Имя пользователя</h2>
<div id="reviews-list">
<div class="review">
<div class="review-user">
<img src="../assets/avatar.jpg" alt="Фото пользователя" class="user-photo">
<img src="/assets/avatar.jpg" alt="Фото пользователя" class="user-photo">
<div class="user-info">
<h4>Имя пользователя</h4>
<p>03.03.2003</p>
Expand Down

0 comments on commit 0bdfcbe

Please sign in to comment.