release/2025-02-20-12-42
This commit is contained in:
parent
75e925419a
commit
5ec569f3c9
@ -25,10 +25,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
http
|
||||
.csrf().disable()
|
||||
.authorizeRequests()
|
||||
/*.antMatchers("/api/employee/**").hasAnyAuthority("ROLE_EMPLOYEE", "ROLE_ADMIN")*/
|
||||
.antMatchers("/api/admin/**").hasAuthority("ROLE_ADMIN")
|
||||
/*.antMatchers("url").permitAll()
|
||||
.antMatchers("url").hasAuthority("ROLE_ADMIN")*/
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.httpBasic()
|
||||
|
@ -42,4 +42,11 @@ public class AdminController {
|
||||
String login = authentication.getName();
|
||||
return adminService.getEmployeeEntryList(employeeLogin, login);
|
||||
}
|
||||
|
||||
@PostMapping("/panel/is-employee-blocked")
|
||||
private boolean isEmployeeBlocked(@RequestParam("employee-login") String employeeLogin,
|
||||
Authentication authentication) {
|
||||
String login = authentication.getName();
|
||||
return adminService.isEmployeeBlocked(employeeLogin, login);
|
||||
}
|
||||
}
|
||||
|
@ -9,4 +9,5 @@ public interface AdminService {
|
||||
EmployeeDataDto getEmployeeInfo(String employeeLogin, String selfLogin);
|
||||
void setBlockCondition(String employeeLogin, boolean blockCondition, String selfLogin);
|
||||
List<EntryDto> getEmployeeEntryList(String employeeLogin, String selfLogin);
|
||||
boolean isEmployeeBlocked(String employeeLogin, String selfLogin);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.infinity.nto.dto.EmployeeDataDto;
|
||||
import com.infinity.nto.dto.EntryDto;
|
||||
import com.infinity.nto.dto.mapper.EmployeeDataMapper;
|
||||
import com.infinity.nto.dto.mapper.EntryMapper;
|
||||
import com.infinity.nto.entity.Employee;
|
||||
import com.infinity.nto.entity.EmployeeData;
|
||||
import com.infinity.nto.exception.EmployeeDataNotFoundException;
|
||||
import com.infinity.nto.exception.EmployeeNotFoundException;
|
||||
@ -76,4 +77,18 @@ public class AdminServiceImpl implements AdminService {
|
||||
.map(EntryMapper::toEntryDto)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmployeeBlocked(String employeeLogin, String selfLogin) {
|
||||
if (employeeLogin.equals(selfLogin)) {
|
||||
throw new SelfChangeException("Self View");
|
||||
}
|
||||
|
||||
Optional<Employee> employee = employeeRepository.findByLogin(employeeLogin);
|
||||
if (employee.isEmpty()) {
|
||||
throw new EmployeeNotFoundException("Employee Not Found");
|
||||
}
|
||||
|
||||
return employee.get().isBlock();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user