lab6 mvc done
This commit is contained in:
parent
e86f9c2d5a
commit
b6b676717c
@ -59,15 +59,4 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/templates/**")
|
||||
.antMatchers("/webjars/**");
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void configure(WebSecurity web) {
|
||||
// web.ignoring()
|
||||
// .antMatchers(HttpMethod.OPTIONS, "/**")
|
||||
// .antMatchers("/**/*.{js,html,css,png}")
|
||||
// .antMatchers("/swagger-ui/index.html")
|
||||
// .antMatchers("/webjars/**")
|
||||
// .antMatchers("/swagger-resources/**")
|
||||
// .antMatchers("/v3/api-docs/**");
|
||||
// }
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -42,7 +43,11 @@ public class AlbumService {
|
||||
User user = userService.findByLogin(username);
|
||||
if(user.getRole() == UserRole.ADMIN){
|
||||
album.setUser(user);
|
||||
} else {
|
||||
throw new AccessDeniedException("User does not have permission to perform this operation");
|
||||
}
|
||||
} else {
|
||||
throw new AccessDeniedException("Authentication required for this operation");
|
||||
}
|
||||
return albumRepository.save(album);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -36,7 +37,11 @@ public class ArtistService {
|
||||
User user = userService.findByLogin(username);
|
||||
if(user.getRole() == UserRole.ADMIN){
|
||||
artist.setUser(user);
|
||||
} else {
|
||||
throw new AccessDeniedException("User does not have permission to perform this operation");
|
||||
}
|
||||
} else {
|
||||
throw new AccessDeniedException("Authentication required for this operation");
|
||||
}
|
||||
return artistRepository.save(artist);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -37,7 +38,11 @@ public class SongService {
|
||||
User user = userService.findByLogin(username);
|
||||
if(user.getRole() == UserRole.ADMIN){
|
||||
song.setUser(user);
|
||||
} else {
|
||||
throw new AccessDeniedException("User does not have permission to perform this operation");
|
||||
}
|
||||
} else {
|
||||
throw new AccessDeniedException("Authentication required for this operation");
|
||||
}
|
||||
return songRepository.save(song);
|
||||
}
|
||||
@ -75,15 +80,4 @@ public class SongService {
|
||||
public void deleteAllSong() {
|
||||
songRepository.deleteAll();
|
||||
}
|
||||
|
||||
// @Transactional
|
||||
// public void AddSongToAlbum(Long idSong, Long idAlbum){
|
||||
// Song song = findSong(idSong);
|
||||
// Album album = em.find(Album.class, idAlbum);
|
||||
// if (album == null || song == null) {
|
||||
// throw new EntityNotFoundException("Album or Song not found");
|
||||
// }
|
||||
// song.setAlbum(album);
|
||||
// em.merge(song);
|
||||
// }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user