Skip to content

Commit

Permalink
Changing logout
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoleNG18 committed Apr 14, 2024
1 parent 71752a8 commit 8b9f264
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class I18NConfig {
@Bean
public LocaleResolver localeResolver() {
CookieLocaleResolver clr = new CookieLocaleResolver();
clr.setCookieName("lang");
clr.setCookieDomain("lang");
return clr;
}
//prihvashta koga potrebitelqt iska da smeni ezika
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.SecurityContextConfigurer;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
Expand Down Expand Up @@ -59,21 +60,11 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws
}
).logout(
logout -> {

try {
logout
// the URL where we should POST something in order to perform the logout
.logoutUrl("/users/logout")
// where to go when logged out?
.logoutSuccessUrl("/")
// invalidate the HTTP session
.invalidateHttpSession(true)
.and().
securityContext().
securityContextRepository(securityContextRepository());
} catch (Exception e) {
throw new RuntimeException(e);
}
logout
.logoutUrl("/users/logout")
.logoutSuccessUrl("/")
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID","lang");
}
)
.build();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/pmgkn/pescores/pescores/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

@Configuration
public class WebConfig implements WebMvcConfigurer {
private LocaleChangeInterceptor localeChangeInterceptor;

private final LocaleChangeInterceptor localeChangeInterceptor;

public WebConfig(LocaleChangeInterceptor localeChangeInterceptor) {
this.localeChangeInterceptor = localeChangeInterceptor;
Expand Down
16 changes: 11 additions & 5 deletions src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
navbar_language=Language
navbar_login=Login
navbar_register=Sign up
navbar_login=Log in
navbar_register=Register
navbar_add_school=How to add your school?
navbar_dense_ball=Dense ball
navbar_jump=Jump
Expand All @@ -19,14 +19,15 @@ home_welcome=Welcome to PE Scores
home_if_dont_have=If you don't have an account - here.
home_if_have=If you have an account - here.
home_login=log in
home_register=sign up
home_register=register
title_home=Home
title_login=Log in
title_register=Register
title_howto=How to add your school?
title_tasks=Tasks
title_add_school=Add school
title_all_schools=All schools
login_login=Log in
login_email=Email
Expand Down Expand Up @@ -60,11 +61,16 @@ tasks_done_todos=Done todos
tasks_finish=Finish until
tasks_up_to=Was up to
add_school_x2=Add school
add_school=Add school
add_school_name=Name
add_school_pmg=PMG 'Prof. Emanuil Ivanov'
add_school_err_name=School name is required
add_school_err_name=School name is required and should be unique
add_school_city=City
add_school_kn=Kyustendil
add_school_err_city=City name is required
add_school_submit=Submit
all_schools=All schools
school_remove_admin=Remove admin
school_make_admin=Make admin
12 changes: 9 additions & 3 deletions src/main/resources/i18n/messages_bg.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ title_register= Регистрация
title_howto= Как да добавите училището си?
title_tasks=Задачи
title_add_school=Добави училище
title_all_schools=Всички училища

login_login= Вход
login_email = Имейл
Expand Down Expand Up @@ -60,11 +61,16 @@ tasks_done_todos=Приключени задачи
tasks_finish=Приключи преди
tasks_up_to=Крайна дата

add_school_x2=Добави училище
add_school=Добави училище
add_school_name=Име
add_school_pmg=ПМГ 'Проф. Емануил Иванов'
add_school_err_name=Името е задължително
add_school_err_name=Името е задължително и трябва да е уникално
add_school_city=Град
add_school_kn=Кюстендил
add_school_err_city=Градът е задължителен
add_school_submit=Добави
add_school_submit=Добави

all_schools=Всички училища

school_remove_admin=Премахни админ
school_make_admin=Направи админ
2 changes: 1 addition & 1 deletion src/main/resources/static/css/school.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
border-radius: 5px;
padding: 0.5em 1em;
text-decoration: none;
font-size: 15px;
font-size: 14px;
font-weight: 500;
border: 1px solid #5d54c3;
}
4 changes: 2 additions & 2 deletions src/main/resources/templates/add-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/add-school.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down Expand Up @@ -67,7 +67,7 @@
th:action="@{/schools/add}"
th:object="${schoolAddDto}">

<h3 th:text="#{add_school_x2}">Add school</h3>
<h3 th:text="#{add_school}">Add school</h3>

<label for="schoolName" class="label" th:text="#{add_school_name}">Name</label>
<input type="text"
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/templates/all-schools.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
<title>All schools</title>
<title th:text="#{title_all_schools}">All schools</title>
<!-- <th:block th:insert="~{/fragments/head}"></th:block>-->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down Expand Up @@ -44,8 +44,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand All @@ -68,7 +68,7 @@
<section class="main-section-schools">

<div class="all-schools">
<h2>All schools</h2>
<h2 th:text="#{all_schools}">All schools</h2>

<ul th:each="school: ${schools}">
<li><a class="className" th:text="*{school.schoolName}"
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/classes-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/current-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/dense-ball.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/jump.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
</ul>
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/templates/school.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down Expand Up @@ -76,14 +76,14 @@ <h2 th:text="${currentSchool.name}">school name</h2>
<form th:method="PATCH"
th:action="@{/users/roles/admin/add/{schoolId}/{id}(schoolId=${currentSchool.id},id=${teacher.id})}"
th:object="${teacher}">
<button>Make admin</button>
<button th:text="#{school_make_admin}">Make admin</button>
</form>
</li>
<li th:if="${teacher.isSchoolAdmin()}" class="buttonRole">
<form th:method="PATCH"
th:action="@{/users/roles/admin/remove/{schoolId}/{id}(schoolId=${currentSchool.id}, id=${teacher.id})}"
th:object="${teacher}">
<button>Remove admin</button>
<button th:text="#{school_remove_admin}">Remove admin</button>
</form>
</li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/student-add.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/t-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/tasks.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/thirty-meters.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<a sec:authorize="!hasAnyAuthority('ROLE_SUPERADMIN')" th:href="@{/students/add}" th:text="#{navbar_add_student}">Add student</a>
<a th:href="@{/tasks}" th:text="#{navbar_tasks}">Tasks</a>
<a>
<form class="logout" th:method="post" th:action="@{/users/logout}" th:text="#{navbar_logout}">
<input class="dropdown-item btn-link nav-link" type="submit" value="Logout">
<form class="logout" th:method="post" th:action="@{/users/logout}">
<input class="dropdown-item btn-link nav-link" type="submit" th:value="#{navbar_logout}">
</form>
</a>
<a class="nav-item">
Expand Down
Loading

0 comments on commit 8b9f264

Please sign in to comment.