Merge branch 'w2p-97298_issue-3281_self-register-issue-7.2' into w2p-97298_issue-3281_self-register-issue-main

This commit is contained in:
Joost
2022-12-20 15:17:53 +01:00
4 changed files with 14 additions and 15 deletions

View File

@@ -14,6 +14,7 @@ import { RemoteData } from './remote-data';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
import { HttpHeaders } from '@angular/common/http';
import {HttpParams} from "@angular/common/http";
@Injectable({
providedIn: 'root',
@@ -55,7 +56,7 @@ export class EpersonRegistrationService {
* @param email
* @param captchaToken the value of x-recaptcha-token header
*/
registerEmail(email: string, captchaToken: string = null): Observable<RemoteData<Registration>> {
registerEmail(email: string, captchaToken: string = null, type?: string): Observable<RemoteData<Registration>> {
const registration = new Registration();
registration.email = email;
@@ -69,6 +70,7 @@ export class EpersonRegistrationService {
headers = headers.append('x-recaptcha-token', captchaToken);
}
options.headers = headers;
options.params = type? new HttpParams({fromString:'type='+type}): new HttpParams();
href$.pipe(
find((href: string) => hasValue(href)),

View File

@@ -1,7 +1,8 @@
<div class="container">
<h2>{{MESSAGE_PREFIX + '.header'|translate}}</h2>
<p>{{MESSAGE_PREFIX + '.info' | translate}}</p>
<p *ngIf="valid_mail_domains.length!= 0">Accounts can be registered for mail addresses of the domains {{ valid_mail_domains.join(", ")}} </p>
<p
*ngIf="validMailDomains.length!= 0 && MESSAGE_PREFIX==='register-page.registration'">{{ MESSAGE_PREFIX + '.info.maildomain' | translate}} {{ validMailDomains.join(", ")}} </p>
<form [class]="'ng-invalid'" [formGroup]="form">

View File

@@ -58,7 +58,7 @@ export class RegisterEmailFormComponent implements OnInit {
captchaMode(): Observable<string> {
return this.googleRecaptchaService.captchaMode();
}
valid_mail_domains: string[];
validMailDomains: string[];
constructor(
private epersonRegistrationService: EpersonRegistrationService,
@@ -85,6 +85,7 @@ export class RegisterEmailFormComponent implements OnInit {
],
})
});
this.validMailDomains = [];
this.configService.findByPropertyName('registration.verification.enabled').pipe(
getFirstSucceededRemoteDataPayload(),
map((res: ConfigurationProperty) => res?.values[0].toLowerCase() === 'true')
@@ -96,16 +97,6 @@ export class RegisterEmailFormComponent implements OnInit {
this.disableUntilChecked = res;
this.changeDetectorRef.detectChanges();
});
this.valid_mail_domains = [];
this.configService.findByPropertyName('authentication-password.domain.valid')
.pipe(getAllCompletedRemoteData())
.subscribe((remoteData) => {
for (const remoteValue of remoteData.payload.values) {
this.valid_mail_domains.push(remoteValue);
}
}
);
}
/**
@@ -154,9 +145,13 @@ export class RegisterEmailFormComponent implements OnInit {
* Registration of an email address
*/
registration(captchaToken = null) {
let typeMap = new Map<string, string>([
["register-page.registration", "register"],
["forgot-email.form", "forgot"]
]);
let registerEmail$ = captchaToken ?
this.epersonRegistrationService.registerEmail(this.email.value, captchaToken) :
this.epersonRegistrationService.registerEmail(this.email.value);
this.epersonRegistrationService.registerEmail(this.email.value, captchaToken, typeMap.get(this.MESSAGE_PREFIX)) :
this.epersonRegistrationService.registerEmail(this.email.value,typeMap.get(this.MESSAGE_PREFIX));
registerEmail$.subscribe((response: RemoteData<Registration>) => {
if (response.hasSucceeded) {
this.notificationService.success(this.translateService.get(`${this.MESSAGE_PREFIX}.success.head`),

View File

@@ -3294,6 +3294,7 @@
"register-page.registration.google-recaptcha.notification.message.error": "An error occurred during reCaptcha verification",
"register-page.registration.google-recaptcha.notification.message.expired": "Verification expired. Please verify again.",
"register-page.registration.info.maildomain": "Accounts can be registered for mail addresses of the domains",
"relationships.add.error.relationship-type.content": "No suitable match could be found for relationship type {{ type }} between the two items",