fix betreft email voor invite en logging van gebruiker info
This commit is contained in:
1
pom.xml
1
pom.xml
@@ -101,6 +101,7 @@
|
|||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*</include>
|
<include>**/*</include>
|
||||||
|
<include>templates/*</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -32,9 +32,7 @@ public class AppointmentResource {
|
|||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Path("/date")
|
@Path("/date")
|
||||||
public List<AppointmentDTO> getAppointmentsByDate(@QueryParam("start") String start) {
|
public List<AppointmentDTO> getAppointmentsByDate(@QueryParam("start") String start) {
|
||||||
System.out.println("getting appointments from " + start);
|
|
||||||
String user = jwt.getClaim("username");
|
String user = jwt.getClaim("username");
|
||||||
System.out.println("user " + user);
|
|
||||||
return appointmentService.getAppointmentsByDate(start, user);
|
return appointmentService.getAppointmentsByDate(start, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,24 +26,6 @@ public class AuthResource {
|
|||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @POST
|
|
||||||
// @Path("/login")
|
|
||||||
// @PermitAll
|
|
||||||
// @Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
// public Response login(AuthDTO user) {
|
|
||||||
// System.out.println(user);
|
|
||||||
// System.out.println("admin".equals(user.getUsername()) && "password".equals(user.getPassword()));
|
|
||||||
// if ("admin".equals(user.getUsername()) && "password".equals(user.getPassword())) {
|
|
||||||
// UserDTO userDTO = new UserDTO();
|
|
||||||
// userDTO.setUsername(user.getUsername());
|
|
||||||
// userDTO.setEmail("vanveenmel11@gmail.com");
|
|
||||||
// userDTO.setFullName("Mel van Veen");
|
|
||||||
// userDTO.setToken(tokenService.generateToken(user.getUsername()));
|
|
||||||
// return Response.ok(userDTO).build();
|
|
||||||
// }
|
|
||||||
// return Response.status(Response.Status.UNAUTHORIZED).build();
|
|
||||||
// }
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/login")
|
@Path("/login")
|
||||||
public Response login(AppUser user) {
|
public Response login(AppUser user) {
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ public class CompanyResource {
|
|||||||
@POST
|
@POST
|
||||||
@Path("/link")
|
@Path("/link")
|
||||||
public void linkCompany(@QueryParam("user") Long userId, @QueryParam("token") String token) {
|
public void linkCompany(@QueryParam("user") Long userId, @QueryParam("token") String token) {
|
||||||
this.companyService.linkCompany(userId, token);
|
this.companyService.linkCompanyWithInvite(userId, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/link/noInvite")
|
||||||
|
public void linkCompanyToNewUser(@QueryParam("user") Long userId, @QueryParam("company") Long companyId) {
|
||||||
|
this.companyService.linkCompany(userId, companyId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,12 +60,8 @@ public class AppointmentService {
|
|||||||
public List<AppointmentDTO> getAppointmentsByDate(String start, String username) {
|
public List<AppointmentDTO> getAppointmentsByDate(String start, String username) {
|
||||||
LocalDate date = LocalDate.parse(start);
|
LocalDate date = LocalDate.parse(start);
|
||||||
AppUser user = userRepository.findByUsername(username);
|
AppUser user = userRepository.findByUsername(username);
|
||||||
System.out.println("user " + user);
|
|
||||||
AppUserDTO appUserDTO = AppUserMapper.toDTO(user);
|
AppUserDTO appUserDTO = AppUserMapper.toDTO(user);
|
||||||
System.out.println("appUserDTO " + appUserDTO);
|
|
||||||
Set<Long> companies = appUserDTO.getCompanies().stream().map(UserCompanyDTO::getCompany).map(CompanyDTO::getId).collect(Collectors.toSet());
|
Set<Long> companies = appUserDTO.getCompanies().stream().map(UserCompanyDTO::getCompany).map(CompanyDTO::getId).collect(Collectors.toSet());
|
||||||
System.out.println("companies " + companies);
|
|
||||||
|
|
||||||
|
|
||||||
LocalDateTime startOfDay = date.atStartOfDay();
|
LocalDateTime startOfDay = date.atStartOfDay();
|
||||||
LocalDateTime endOfDay = date.atTime(23, 59, 59);
|
LocalDateTime endOfDay = date.atTime(23, 59, 59);
|
||||||
|
|||||||
@@ -37,19 +37,23 @@ public class CompanyService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void linkCompany(Long userId, String token) {
|
public void linkCompanyWithInvite(Long userId, String token) {
|
||||||
AppUser user = userRepository.findById(userId);
|
|
||||||
InviteEntity invite = inviteRepository.findByToken(token);
|
InviteEntity invite = inviteRepository.findByToken(token);
|
||||||
Company company = companyRepository.findById(invite.company_id);
|
linkCompany(userId, invite.company_id);
|
||||||
|
|
||||||
|
invite.used = true;
|
||||||
|
inviteRepository.persist(invite);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void linkCompany(Long userId, Long companyId) {
|
||||||
|
AppUser user = userRepository.findById(userId);
|
||||||
|
Company company = companyRepository.findById(companyId);
|
||||||
|
|
||||||
UserCompany userCompany = new UserCompany();
|
UserCompany userCompany = new UserCompany();
|
||||||
userCompany.setUser(user);
|
userCompany.setUser(user);
|
||||||
userCompany.setCompany(company);
|
userCompany.setCompany(company);
|
||||||
userCompany.setAccessLevel(AccessLevel.USER);
|
userCompany.setAccessLevel(AccessLevel.USER);
|
||||||
userCompanyRepository.persist(userCompany);
|
userCompanyRepository.persist(userCompany);
|
||||||
|
|
||||||
invite.used = true;
|
|
||||||
inviteRepository.persist(invite);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user