#8952 - fix bug when merging two accounts did not have consistent behaviour.
This commit is contained in:
parent
634d49ea35
commit
30abe4d4c9
|
@ -32,16 +32,16 @@ public class EmailMergeConfirmation {
|
|||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/{emailToken}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem> emailConfirmation(@PathVariable(value = "emailToken") String token) {
|
||||
ResponseEntity<ResponseItem<String>> emailConfirmation(@PathVariable(value = "emailToken") String token) {
|
||||
try {
|
||||
this.emailConfirmationManager.confirmEmail(token);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
String emailToBeMerged = this.emailConfirmationManager.confirmEmail(token);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().payload(emailToBeMerged).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
} catch
|
||||
(HasConfirmedEmailException | TokenExpiredException ex) {
|
||||
if (ex instanceof TokenExpiredException) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE));
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.NO_MESSAGE));
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem().status(ApiMessageCode.WARN_MESSAGE));
|
||||
return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem<String>().status(ApiMessageCode.WARN_MESSAGE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MergeEmailConfirmationManager {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public void confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException {
|
||||
public String confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException {
|
||||
EmailConfirmation loginConfirmationEmail = apiContext.getOperationsContext()
|
||||
.getDatabaseRepository().getLoginConfirmationEmailDao().asQueryable()
|
||||
.where((builder, root) -> builder.equal(root.get("token"), UUID.fromString(token))).getSingle();
|
||||
|
@ -57,7 +57,7 @@ public class MergeEmailConfirmationManager {
|
|||
|
||||
UserInfo userToBeMerged = databaseRepository.getUserInfoDao().asQueryable()
|
||||
.where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle();
|
||||
|
||||
String userToBeMergedEmail = userToBeMerged.getEmail();
|
||||
try {
|
||||
Map<String, Object> map = new ObjectMapper().readValue(loginConfirmationEmail.getData(), HashMap.class);
|
||||
UUID otherUserId = UUID.fromString((String) map.get("userId"));
|
||||
|
@ -72,6 +72,8 @@ public class MergeEmailConfirmationManager {
|
|||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
return userToBeMergedEmail;
|
||||
}
|
||||
|
||||
public void sendConfirmationEmail(String email, Principal principal, UUID userId, Integer provider) throws HasConfirmedEmailException {
|
||||
|
|
|
@ -38,7 +38,7 @@ export class AuthService extends BaseService {
|
|||
this.headers = this.headers.set('Accept', 'application/json');
|
||||
}
|
||||
|
||||
private clear(): void {
|
||||
public clear(): void {
|
||||
localStorage.removeItem('principal');
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Component, OnInit } from "@angular/core";
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { AuthService } from "@app/core/services/auth/auth.service";
|
||||
import { EmailConfirmationService } from '@app/core/services/email-confirmation/email-confirmation.service';
|
||||
import { MergeEmailConfirmationService } from '@app/core/services/merge-email-confirmation/merge-email-confirmation.service';
|
||||
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
||||
|
@ -20,6 +21,7 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit {
|
|||
|
||||
constructor(
|
||||
private emailConfirmationService: MergeEmailConfirmationService,
|
||||
private authService: AuthService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private language: TranslateService,
|
||||
|
@ -36,7 +38,13 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit {
|
|||
this.emailConfirmationService.emailConfirmation(token)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
result => this.onCallbackEmailConfirmationSuccess(),
|
||||
result => {
|
||||
const principal = this.authService.current();
|
||||
if(!principal || !result || (principal.email == result))
|
||||
this.authService.clear();
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('USER-PROFILE.MERGING-SUCCESS'), SnackBarNotificationLevel.Success);
|
||||
this.onCallbackEmailConfirmationSuccess();
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
)
|
||||
} else {
|
||||
|
|
|
@ -1687,13 +1687,14 @@
|
|||
"LOG-OUT": "Abmeldung"
|
||||
},
|
||||
"USER-PROFILE": {
|
||||
"MERGING-SUCCESS": "Linking of the two profiles was successful.",
|
||||
"MERGING-EMAILS-DIALOG": {
|
||||
"TITLE": "Verify linked account",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, you will be able to see your accounts merged. The last email account that you merge will be the one containing all of your DMP records and activity in {{ APP_NAME }}."
|
||||
},
|
||||
"UNLINK-ACCOUNT": {
|
||||
"TITLE": "Verify account to be unlinked",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, {{accountToBeUnlinked}} will be unlinked."
|
||||
"MESSAGE": "An email to verify this action has been sent to your main account. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
},
|
||||
"UNLINK-ACCOUNT-DIALOG": {
|
||||
"MESSAGE": "By clicking \"Confirm\", you accept the transfer of your ARGOS activity performed from this account to your main ARGOS account, which is the one that is listed first. By logging in again with the unlinked account, you will be able to start your ARGOS experience from scratch, in an empty dashboard.",
|
||||
|
|
|
@ -1687,13 +1687,14 @@
|
|||
"LOG-OUT": "Log Out"
|
||||
},
|
||||
"USER-PROFILE": {
|
||||
"MERGING-SUCCESS": "Linking of the two profiles was successful.",
|
||||
"MERGING-EMAILS-DIALOG": {
|
||||
"TITLE": "Verify linked account",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, you will be able to see your accounts merged. The last email account that you merge will be the one containing all of your DMP records and activity in {{ APP_NAME }}."
|
||||
},
|
||||
"UNLINK-ACCOUNT": {
|
||||
"TITLE": "Verify account to be unlinked",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
"MESSAGE": "An email to verify this action has been sent to your main account. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
},
|
||||
"UNLINK-ACCOUNT-DIALOG": {
|
||||
"MESSAGE": "By clicking \"Confirm\", you accept the transfer of your ARGOS activity performed from this account to your main ARGOS account, which is the one that is listed first. By logging in again with the unlinked account, you will be able to start your ARGOS experience from scratch, in an empty dashboard.",
|
||||
|
|
|
@ -1687,13 +1687,14 @@
|
|||
"LOG-OUT": "Cerrar la sesión"
|
||||
},
|
||||
"USER-PROFILE": {
|
||||
"MERGING-SUCCESS": "Linking of the two profiles was successful.",
|
||||
"MERGING-EMAILS-DIALOG": {
|
||||
"TITLE": "Verify linked account",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, you will be able to see your accounts merged. The last email account that you merge will be the one containing all of your DMP records and activity in {{ APP_NAME }}."
|
||||
},
|
||||
"UNLINK-ACCOUNT": {
|
||||
"TITLE": "Verify account to be unlinked",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, {{accountToBeUnlinked}} will be unlinked."
|
||||
"MESSAGE": "An email to verify this action has been sent to your main account. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
},
|
||||
"UNLINK-ACCOUNT-DIALOG": {
|
||||
"MESSAGE": "By clicking \"Confirm\", you accept the transfer of your ARGOS activity performed from this account to your main ARGOS account, which is the one that is listed first. By logging in again with the unlinked account, you will be able to start your ARGOS experience from scratch, in an empty dashboard.",
|
||||
|
|
|
@ -1687,13 +1687,14 @@
|
|||
"LOG-OUT": "Αποσύνδεση"
|
||||
},
|
||||
"USER-PROFILE": {
|
||||
"MERGING-SUCCESS": "Linking of the two profiles was successful.",
|
||||
"MERGING-EMAILS-DIALOG": {
|
||||
"TITLE": "Verify linked account",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, you will be able to see your accounts merged. The last email account that you merge will be the one containing all of your DMP records and activity in {{ APP_NAME }}."
|
||||
},
|
||||
"UNLINK-ACCOUNT": {
|
||||
"TITLE": "Verify account to be unlinked",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, {{accountToBeUnlinked}} will be unlinked."
|
||||
"MESSAGE": "An email to verify this action has been sent to your main account. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
},
|
||||
"UNLINK-ACCOUNT-DIALOG": {
|
||||
"MESSAGE": "By clicking \"Confirm\", you accept the transfer of your ARGOS activity performed from this account to your main ARGOS account, which is the one that is listed first. By logging in again with the unlinked account, you will be able to start your ARGOS experience from scratch, in an empty dashboard.",
|
||||
|
|
|
@ -1687,13 +1687,14 @@
|
|||
"LOG-OUT": "Odjava"
|
||||
},
|
||||
"USER-PROFILE": {
|
||||
"MERGING-SUCCESS": "Linking of the two profiles was successful.",
|
||||
"MERGING-EMAILS-DIALOG": {
|
||||
"TITLE": "Potvrdi povezani korisnički račun",
|
||||
"MESSAGE": "Potvrdu za ovu radnju poslali smo Vam putem elektroničke pošte. Kada potvrdite, korisnički računi biti će povezani. Posljednji račun elektroničke pošte koji povežete biti će onaj koji sadrži sve podatke o Planu upravljanja podacima i aktivnostima u {{ APP_NAME }}u."
|
||||
},
|
||||
"UNLINK-ACCOUNT": {
|
||||
"TITLE": "Verify account to be unlinked",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, {{accountToBeUnlinked}} will be unlinked."
|
||||
"MESSAGE": "An email to verify this action has been sent to your main account. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
},
|
||||
"UNLINK-ACCOUNT-DIALOG": {
|
||||
"MESSAGE": "By clicking \"Confirm\", you accept the transfer of your ARGOS activity performed from this account to your main ARGOS account, which is the one that is listed first. By logging in again with the unlinked account, you will be able to start your ARGOS experience from scratch, in an empty dashboard.",
|
||||
|
|
|
@ -1687,13 +1687,14 @@
|
|||
"LOG-OUT": "Wyloguj"
|
||||
},
|
||||
"USER-PROFILE": {
|
||||
"MERGING-SUCCESS": "Linking of the two profiles was successful.",
|
||||
"MERGING-EMAILS-DIALOG": {
|
||||
"TITLE": "Zweryfikuj połączone konto",
|
||||
"MESSAGE": "Wysłano wiadomość e-mail w celu weryfikacji tej akcji. Po zaakceptowaniu będzie można zobaczyć połączone konta. Ostatnie połączone konto e-mail będzie tym, które zawiera wszystkie twoje rejestry DMP i aktywność w {{ APP_NAME }}."
|
||||
},
|
||||
"UNLINK-ACCOUNT": {
|
||||
"TITLE": "Verify account to be unlinked",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, {{accountToBeUnlinked}} will be unlinked."
|
||||
"MESSAGE": "An email to verify this action has been sent to your main account. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
},
|
||||
"UNLINK-ACCOUNT-DIALOG": {
|
||||
"MESSAGE": "By clicking \"Confirm\", you accept the transfer of your ARGOS activity performed from this account to your main ARGOS account, which is the one that is listed first. By logging in again with the unlinked account, you will be able to start your ARGOS experience from scratch, in an empty dashboard.",
|
||||
|
|
|
@ -1687,13 +1687,14 @@
|
|||
"LOG-OUT": "Terminar Sessão"
|
||||
},
|
||||
"USER-PROFILE": {
|
||||
"MERGING-SUCCESS": "Linking of the two profiles was successful.",
|
||||
"MERGING-EMAILS-DIALOG": {
|
||||
"TITLE": "Verify linked account",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, you will be able to see your accounts merged. The last email account that you merge will be the one containing all of your DMP records and activity in {{ APP_NAME }}."
|
||||
},
|
||||
"UNLINK-ACCOUNT": {
|
||||
"TITLE": "Verify account to be unlinked",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, {{accountToBeUnlinked}} will be unlinked."
|
||||
"MESSAGE": "An email to verify this action has been sent to your main account. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
},
|
||||
"UNLINK-ACCOUNT-DIALOG": {
|
||||
"MESSAGE": "By clicking \"Confirm\", you accept the transfer of your ARGOS activity performed from this account to your main ARGOS account, which is the one that is listed first. By logging in again with the unlinked account, you will be able to start your ARGOS experience from scratch, in an empty dashboard.",
|
||||
|
|
|
@ -1687,13 +1687,14 @@
|
|||
"LOG-OUT": "Odhlásiť sa"
|
||||
},
|
||||
"USER-PROFILE": {
|
||||
"MERGING-SUCCESS": "Linking of the two profiles was successful.",
|
||||
"MERGING-EMAILS-DIALOG": {
|
||||
"TITLE": "Verify linked account",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, you will be able to see your accounts merged. The last email account that you merge will be the one containing all of your DMP records and activity in {{ APP_NAME }}."
|
||||
},
|
||||
"UNLINK-ACCOUNT": {
|
||||
"TITLE": "Verify account to be unlinked",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, {{accountToBeUnlinked}} will be unlinked."
|
||||
"MESSAGE": "An email to verify this action has been sent to your main account. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
},
|
||||
"UNLINK-ACCOUNT-DIALOG": {
|
||||
"MESSAGE": "By clicking \"Confirm\", you accept the transfer of your ARGOS activity performed from this account to your main ARGOS account, which is the one that is listed first. By logging in again with the unlinked account, you will be able to start your ARGOS experience from scratch, in an empty dashboard.",
|
||||
|
|
|
@ -1687,13 +1687,14 @@
|
|||
"LOG-OUT": "Odjavite se"
|
||||
},
|
||||
"USER-PROFILE": {
|
||||
"MERGING-SUCCESS": "Linking of the two profiles was successful.",
|
||||
"MERGING-EMAILS-DIALOG": {
|
||||
"TITLE": "Verify linked account",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, you will be able to see your accounts merged. The last email account that you merge will be the one containing all of your DMP records and activity in {{ APP_NAME }}."
|
||||
},
|
||||
"UNLINK-ACCOUNT": {
|
||||
"TITLE": "Verify account to be unlinked",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, {{accountToBeUnlinked}} will be unlinked."
|
||||
"MESSAGE": "An email to verify this action has been sent to your main account. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
},
|
||||
"UNLINK-ACCOUNT-DIALOG": {
|
||||
"MESSAGE": "By clicking \"Confirm\", you accept the transfer of your ARGOS activity performed from this account to your main ARGOS account, which is the one that is listed first. By logging in again with the unlinked account, you will be able to start your ARGOS experience from scratch, in an empty dashboard.",
|
||||
|
|
|
@ -1687,13 +1687,14 @@
|
|||
"LOG-OUT": "Çıkış Yap"
|
||||
},
|
||||
"USER-PROFILE": {
|
||||
"MERGING-SUCCESS": "Linking of the two profiles was successful.",
|
||||
"MERGING-EMAILS-DIALOG": {
|
||||
"TITLE": "Verify linked account",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, you will be able to see your accounts merged. The last email account that you merge will be the one containing all of your DMP records and activity in {{ APP_NAME }}."
|
||||
},
|
||||
"UNLINK-ACCOUNT": {
|
||||
"TITLE": "Verify account to be unlinked",
|
||||
"MESSAGE": "An email to verify this action has been sent to you. Once accepted, {{accountToBeUnlinked}} will be unlinked."
|
||||
"MESSAGE": "An email to verify this action has been sent to your main account. Once accepted, {{accountToBeUnlinked}} will be no longer connected to your current ARGOS profile."
|
||||
},
|
||||
"UNLINK-ACCOUNT-DIALOG": {
|
||||
"MESSAGE": "By clicking \"Confirm\", you accept the transfer of your ARGOS activity performed from this account to your main ARGOS account, which is the one that is listed first. By logging in again with the unlinked account, you will be able to start your ARGOS experience from scratch, in an empty dashboard.",
|
||||
|
|
Loading…
Reference in New Issue