Compare commits

..

2 Commits

Author SHA1 Message Date
7e7cec2f6c Merge branch 'Max/Backend/GetUserById' into wal/front/listingUsers
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m2s
Build and test backend / Test-backend (pull_request) Successful in 1m57s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 23s
2024-03-17 22:00:56 +01:00
345599888d added GET /user/{id}
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m59s
Build and test backend / Test-backend (pull_request) Successful in 1m56s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 23s
2024-03-17 21:48:58 +01:00
5 changed files with 18 additions and 7 deletions

View File

@ -40,6 +40,16 @@ public class UserController {
return new ResponseEntity<>(ProtectionService.userWithoutPassword(user), HttpStatus.OK);
}
@GetMapping("/user/{id}")
public ResponseEntity<HashMap<String ,Object>> getUserById(@RequestHeader("Authorization") String token, @PathVariable Long id){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
return new UnauthorizedResponse<>(null);
return new ResponseEntity<>(ProtectionService.userWithoutPassword(userService.getUserById(id)), HttpStatus.OK);
}
@PostMapping("/user")
public ResponseEntity<Map<String ,Object>> postUser(@RequestBody User user,@RequestHeader("Authorization") String token){

View File

@ -122,4 +122,9 @@ public class UserService {
public Iterable<User> getAllTeachers (){return userRepo.findAllTeachers();}
public Iterable<User> getAllStudents(){return userRepo.findAllStudents();}
public User getUserById(long id) {
return userRepo.findById(id);
}
}

View File

@ -12,11 +12,7 @@ window.onhashchange = function() {
prevURL = currentURL;
currentURL = window.location.hash;
}
console.log(location)
window.addEventListener('hashchange', () => {
console.log(prevURL)
console.log(location.hash)
console.log(isLogged())
if(location.hash === "#/home" && prevURL === "#/login"){
window.location.reload();
}

View File

@ -2,7 +2,7 @@
import i18n from "@/i18n.js"
import {ref} from 'vue'
import { getCourses,deleteCourse,alterCourse,createCourse } from "@/rest/courses.js"
import {getSelf, getTeachers } from "@/rest/Users.js"
import {getUser, getSelf, getTeachers } from "@/rest/Users.js"
const self = await getSelf();
@ -108,7 +108,7 @@
<div style="margin-bottom:20px;">
{{i18n("Teacher")}} :
<select style="max-width:200px;" class="teacher" v-model="toAdd.owner">
<option v-for="item in profList">{{item.regNo}}</option>
<option v-for="item in profList">{{item}}</option>
</select>
</div>
<div style="margin-bottom:20px;">

View File

@ -72,7 +72,7 @@ export async function createUser(firstname, lastname, birthDate, email, address,
* if the user is not authenticated. then an empty array should be returned
*/
export async function getUser(id){
const endpoint = "/user" + id != null ? "/" + id : "";
const endpoint = "/user/" + id;
return restGet(endpoint);
}