diff --git a/Frontend/vue-project/src/App.vue b/Frontend/vue-project/src/App.vue index 7594bdb..51789cf 100644 --- a/Frontend/vue-project/src/App.vue +++ b/Frontend/vue-project/src/App.vue @@ -5,7 +5,39 @@ components: { Header, Footer - } + }, + data() { + return { + tokenFromServer: undefined, + userFromServer: undefined, + securityError: false, + } + }, + created() { + const self = this + window.addEventListener('storage', function(e){ + console.log(e) + if(e.key === "token") + if(this.tokenFromServer !== e.newValue) { + self.storageSecurity() + } + if(e.key === "user") + if(this.userFromServer !== e.newValue) { + self.storageSecurity() + } + }) + }, + methods: { + storageSecurity(){ + localStorage.clear() + this.$router.push("/login") + this.securityError = true + }, + saveServerData(data){ + this.tokenFromServer = data.token + this.userFromServer = data.user + }, + }, } diff --git a/data.mv.db b/data.mv.db index ebed62d..2149c84 100644 Binary files a/data.mv.db and b/data.mv.db differ diff --git a/src/main/java/ru/ulstu/is/lab1/DataBase/controller/UserController.java b/src/main/java/ru/ulstu/is/lab1/DataBase/controller/UserController.java index c5d6d6f..0793766 100644 --- a/src/main/java/ru/ulstu/is/lab1/DataBase/controller/UserController.java +++ b/src/main/java/ru/ulstu/is/lab1/DataBase/controller/UserController.java @@ -2,7 +2,9 @@ package ru.ulstu.is.lab1.DataBase.controller; import ru.ulstu.is.lab1.DataBase.configuration.OpenAPI30Configuration; import ru.ulstu.is.lab1.DataBase.model.User; +import ru.ulstu.is.lab1.DataBase.model.UserRole; import ru.ulstu.is.lab1.DataBase.service.UserService; +import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -19,6 +21,7 @@ public class UserController { this.userService = userService; } @GetMapping(OpenAPI30Configuration.API_PREFIX + "/user") + @Secured({UserRole.AsString.ADMIN}) public List getUsers() { return userService.findAllUsers(); }