add requestId in logs + check invitation email ignore case (#48)

* add requestId in logs + check invitation email ignore case

* fix test

Co-authored-by: ggmaleva <ggmaleva@yandex.ru>
This commit is contained in:
Gregory 2022-12-07 17:00:46 +03:00 committed by GitHub
parent e4979f66c1
commit 5cc277db68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -27,7 +27,7 @@ public class UserController implements UserApi {
public ResponseEntity<Void> cancelOrgMembership(
String requestId,
String orgId) {
log.info("Cancel org membership: orgId={}", orgId);
log.info("Cancel org membership: requestId={}, orgId={}", requestId, orgId);
ResourceDto resource = ResourceDto.builder()
.orgId(orgId)
.build();
@ -40,7 +40,7 @@ public class UserController implements UserApi {
public ResponseEntity<OrganizationMembership> inquireOrgMembership(
String requestId,
String orgId) {
log.info("Inquire org membership: orgId={}", orgId);
log.info("Inquire org membership: requestId={}, orgId={}", requestId, orgId);
ResourceDto resource = ResourceDto.builder()
.orgId(orgId)
.build();
@ -53,7 +53,7 @@ public class UserController implements UserApi {
public ResponseEntity<OrganizationMembership> joinOrg(
String requestId,
OrganizationJoinRequest body) {
log.info("Join organization: body={}", body);
log.info("Join organization: requestId={}, body ={}", requestId, body);
ResourceDto resource = ResourceDto.builder()
.invitationToken(body.getInvitation())
.build();
@ -67,7 +67,8 @@ public class UserController implements UserApi {
public ResponseEntity<OrganizationSearchResult> listOrgMembership(String requestId,
Integer limit,
String continuationToken) {
log.info("List org membership: limit={}, continuationToken={}", limit, continuationToken);
log.info("List org membership: requestId={}, limit={}, continuationToken={}",
requestId, limit, continuationToken);
resourceAccessService.checkRights();
AccessToken accessToken = keycloakService.getAccessToken();
OrganizationSearchResult organizationSearchResult =

View File

@ -236,7 +236,7 @@ public class OrganizationService {
@Transactional
public OrganizationMembership joinOrganization(String token, String userId, String userEmail) {
InvitationEntity invitationEntity = invitationService.findByToken(token);
if (!userEmail.equals(invitationEntity.getInviteeContactEmail())) {
if (!userEmail.equalsIgnoreCase(invitationEntity.getInviteeContactEmail())) {
log.error("joinOrganization() - error: user email = {} doesn't equals invitee email = {}",
userEmail, invitationEntity.getInviteeContactEmail());
throw new AccessDeniedException(

View File

@ -1,5 +1,6 @@
package dev.vality.orgmanager.util;
import dev.vality.orgmanager.TestObjectFactory;
import dev.vality.orgmanager.entity.InvitationEntity;
import dev.vality.orgmanager.entity.MemberEntity;
import dev.vality.orgmanager.entity.MemberRoleEntity;
@ -35,7 +36,7 @@ public class TestData {
.createdAt(LocalDateTime.now())
.name("name")
.owner("owner")
.party("party")
.party(TestObjectFactory.randomString())
.members(Set.of(member))
.build();
}