mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 20:47:32 +00:00
fix: login text changes (#4269)
* fix: omit empty (zero) dates * overwrite current date on save * update date on reset * smtp * disable reset Co-authored-by: Max Peintner <max@caos.ch>
This commit is contained in:
@@ -62,10 +62,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<!-- *ngIf="totalCustomPolicy && totalCustomPolicy.isDefault === false" -->
|
|
||||||
<button
|
<button
|
||||||
class="reset-button"
|
class="reset-button"
|
||||||
[disabled]="(canWrite$ | async) === false"
|
[disabled]="(canWrite$ | async) === false || isDefault"
|
||||||
(click)="resetDefault()"
|
(click)="resetDefault()"
|
||||||
color="warn"
|
color="warn"
|
||||||
type="submit"
|
type="submit"
|
||||||
@@ -76,7 +75,7 @@
|
|||||||
<button
|
<button
|
||||||
class="save-button"
|
class="save-button"
|
||||||
[disabled]="(canWrite$ | async) === false"
|
[disabled]="(canWrite$ | async) === false"
|
||||||
(click)="saveCurrentMessage()"
|
(click)="saveCurrentTexts()"
|
||||||
color="primary"
|
color="primary"
|
||||||
type="submit"
|
type="submit"
|
||||||
mat-raised-button
|
mat-raised-button
|
||||||
|
@@ -24,6 +24,8 @@ import { WarnDialogComponent } from '../../warn-dialog/warn-dialog.component';
|
|||||||
import { PolicyComponentServiceType } from '../policy-component-types.enum';
|
import { PolicyComponentServiceType } from '../policy-component-types.enum';
|
||||||
import { mapRequestValues } from './helper';
|
import { mapRequestValues } from './helper';
|
||||||
|
|
||||||
|
const MIN_INTERVAL_SECONDS = 10; // if the difference of a newer version to the current exceeds this time, a refresh button is shown.
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
const KeyNamesArray = [
|
const KeyNamesArray = [
|
||||||
'emailVerificationDoneText',
|
'emailVerificationDoneText',
|
||||||
@@ -120,6 +122,8 @@ export class LoginTextsComponent implements OnInit, OnDestroy {
|
|||||||
locale: new UntypedFormControl('en'),
|
locale: new UntypedFormControl('en'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
public isDefault: boolean = false;
|
||||||
|
|
||||||
public canWrite$: Observable<boolean> = this.authService.isAllowed([
|
public canWrite$: Observable<boolean> = this.authService.isAllowed([
|
||||||
this.serviceType === PolicyComponentServiceType.ADMIN
|
this.serviceType === PolicyComponentServiceType.ADMIN
|
||||||
? 'iam.policy.write'
|
? 'iam.policy.write'
|
||||||
@@ -138,7 +142,7 @@ export class LoginTextsComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe((pair) => {
|
.subscribe((pair) => {
|
||||||
this.checkForUnsaved(pair[0].currentSubMap).then((wantsToSave) => {
|
this.checkForUnsaved(pair[0].currentSubMap).then((wantsToSave) => {
|
||||||
if (wantsToSave) {
|
if (wantsToSave) {
|
||||||
this.saveCurrentMessage()
|
this.saveCurrentTexts()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
})
|
})
|
||||||
@@ -200,7 +204,6 @@ export class LoginTextsComponent implements OnInit, OnDestroy {
|
|||||||
return (this.service as ManagementService).getCustomLoginTexts(req).then((res) => {
|
return (this.service as ManagementService).getCustomLoginTexts(req).then((res) => {
|
||||||
if (res.customText) {
|
if (res.customText) {
|
||||||
this.currentPolicyChangeDate = res.customText.details?.changeDate;
|
this.currentPolicyChangeDate = res.customText.details?.changeDate;
|
||||||
// delete res.customText.details;
|
|
||||||
return Object.assign({}, res.customText);
|
return Object.assign({}, res.customText);
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
@@ -219,6 +222,8 @@ export class LoginTextsComponent implements OnInit, OnDestroy {
|
|||||||
.then((policy) => {
|
.then((policy) => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
if (policy) {
|
if (policy) {
|
||||||
|
this.isDefault = policy.isDefault ?? false;
|
||||||
|
|
||||||
this.totalCustomPolicy = policy;
|
this.totalCustomPolicy = policy;
|
||||||
this.getCustomInitMessageTextMap$.next(policy[this.currentSubMap]);
|
this.getCustomInitMessageTextMap$.next(policy[this.currentSubMap]);
|
||||||
}
|
}
|
||||||
@@ -280,7 +285,7 @@ export class LoginTextsComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public saveCurrentMessage(): Promise<any> {
|
public saveCurrentTexts(): Promise<any> {
|
||||||
const entirePayload = this.updateRequest.toObject();
|
const entirePayload = this.updateRequest.toObject();
|
||||||
this.getCustomInitMessageTextMap$.next((entirePayload as any)[this.currentSubMap]);
|
this.getCustomInitMessageTextMap$.next((entirePayload as any)[this.currentSubMap]);
|
||||||
|
|
||||||
@@ -289,6 +294,8 @@ export class LoginTextsComponent implements OnInit, OnDestroy {
|
|||||||
return (this.service as ManagementService)
|
return (this.service as ManagementService)
|
||||||
.setCustomLoginText(this.updateRequest)
|
.setCustomLoginText(this.updateRequest)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
this.updateCurrentPolicyDate();
|
||||||
|
this.isDefault = false;
|
||||||
this.toast.showInfo('POLICY.MESSAGE_TEXTS.TOAST.UPDATED', true);
|
this.toast.showInfo('POLICY.MESSAGE_TEXTS.TOAST.UPDATED', true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.patchSingleCurrentMap();
|
this.patchSingleCurrentMap();
|
||||||
@@ -299,12 +306,33 @@ export class LoginTextsComponent implements OnInit, OnDestroy {
|
|||||||
return (this.service as AdminService)
|
return (this.service as AdminService)
|
||||||
.setCustomLoginText(this.updateRequest)
|
.setCustomLoginText(this.updateRequest)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
this.updateCurrentPolicyDate();
|
||||||
|
this.isDefault = false;
|
||||||
this.toast.showInfo('POLICY.MESSAGE_TEXTS.TOAST.UPDATED', true);
|
this.toast.showInfo('POLICY.MESSAGE_TEXTS.TOAST.UPDATED', true);
|
||||||
})
|
})
|
||||||
.catch((error) => this.toast.showError(error));
|
.catch((error) => this.toast.showError(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updateCurrentPolicyDate(): void {
|
||||||
|
const ts = new Timestamp();
|
||||||
|
const milliseconds = new Date().getTime();
|
||||||
|
const seconds = Math.abs(milliseconds / 1000);
|
||||||
|
const nanos = (milliseconds - seconds * 1000) * 1000 * 1000;
|
||||||
|
ts.setSeconds(seconds);
|
||||||
|
ts.setNanos(nanos);
|
||||||
|
|
||||||
|
if (this.currentPolicyChangeDate) {
|
||||||
|
const oldDate = new Date(
|
||||||
|
this.currentPolicyChangeDate.seconds * 1000 + this.currentPolicyChangeDate.nanos / 1000 / 1000,
|
||||||
|
);
|
||||||
|
const newDate = ts.toDate();
|
||||||
|
if (newDate.getTime() > oldDate.getTime()) {
|
||||||
|
this.currentPolicyChangeDate = ts.toObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public resetDefault(): void {
|
public resetDefault(): void {
|
||||||
const dialogRef = this.dialog.open(WarnDialogComponent, {
|
const dialogRef = this.dialog.open(WarnDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
@@ -323,6 +351,8 @@ export class LoginTextsComponent implements OnInit, OnDestroy {
|
|||||||
(this.service as ManagementService)
|
(this.service as ManagementService)
|
||||||
.resetCustomLoginTextToDefault(this.locale)
|
.resetCustomLoginTextToDefault(this.locale)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
this.updateCurrentPolicyDate();
|
||||||
|
this.isDefault = true;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@@ -334,6 +364,7 @@ export class LoginTextsComponent implements OnInit, OnDestroy {
|
|||||||
(this.service as AdminService)
|
(this.service as AdminService)
|
||||||
.resetCustomLoginTextToDefault(this.locale)
|
.resetCustomLoginTextToDefault(this.locale)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
this.updateCurrentPolicyDate();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@@ -359,7 +390,7 @@ export class LoginTextsComponent implements OnInit, OnDestroy {
|
|||||||
if (this.newerPolicyChangeDate && this.currentPolicyChangeDate) {
|
if (this.newerPolicyChangeDate && this.currentPolicyChangeDate) {
|
||||||
const ms = toDate(this.newerPolicyChangeDate).getTime() - toDate(this.currentPolicyChangeDate).getTime();
|
const ms = toDate(this.newerPolicyChangeDate).getTime() - toDate(this.currentPolicyChangeDate).getTime();
|
||||||
// show button if changes are newer than 10s
|
// show button if changes are newer than 10s
|
||||||
return ms / 1000 > 10;
|
return ms / 1000 > MIN_INTERVAL_SECONDS;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -1524,7 +1524,7 @@
|
|||||||
"DELETE_DESCRIPTION": "You are about to delete an identity provider. The resulting changes are irrevocable. Do you really want to do this?",
|
"DELETE_DESCRIPTION": "You are about to delete an identity provider. The resulting changes are irrevocable. Do you really want to do this?",
|
||||||
"DELETE_SELECTION_TITLE": "Delete Idp",
|
"DELETE_SELECTION_TITLE": "Delete Idp",
|
||||||
"DELETE_SELECTION_DESCRIPTION": "You are about to delete an identity provider. The resulting changes are irrevocable. Do you really want to do this?",
|
"DELETE_SELECTION_DESCRIPTION": "You are about to delete an identity provider. The resulting changes are irrevocable. Do you really want to do this?",
|
||||||
"EMPTY": "No IPD available",
|
"EMPTY": "No IDP available",
|
||||||
"OIDC": {
|
"OIDC": {
|
||||||
"GENERAL": "General Information",
|
"GENERAL": "General Information",
|
||||||
"TITLE": "OIDC Configuration",
|
"TITLE": "OIDC Configuration",
|
||||||
|
@@ -1524,7 +1524,7 @@
|
|||||||
"DELETE_DESCRIPTION": "Vous êtes sur le point de supprimer un fournisseur d'identité. Les changements qui en résultent sont irrévocables. Voulez-vous vraiment le faire ?",
|
"DELETE_DESCRIPTION": "Vous êtes sur le point de supprimer un fournisseur d'identité. Les changements qui en résultent sont irrévocables. Voulez-vous vraiment le faire ?",
|
||||||
"DELETE_SELECTION_TITLE": "Supprimer Idp",
|
"DELETE_SELECTION_TITLE": "Supprimer Idp",
|
||||||
"DELETE_SELECTION_DESCRIPTION": "Vous êtes sur le point de supprimer un fournisseur d'identité. Les changements qui en résultent sont irrévocables. Voulez-vous vraiment le faire ?",
|
"DELETE_SELECTION_DESCRIPTION": "Vous êtes sur le point de supprimer un fournisseur d'identité. Les changements qui en résultent sont irrévocables. Voulez-vous vraiment le faire ?",
|
||||||
"EMPTY": "Aucun IPD disponible",
|
"EMPTY": "Aucun IDP disponible",
|
||||||
"OIDC": {
|
"OIDC": {
|
||||||
"GENERAL": "Informations générales",
|
"GENERAL": "Informations générales",
|
||||||
"TITLE": "Configuration de l'OIDC",
|
"TITLE": "Configuration de l'OIDC",
|
||||||
|
@@ -11,19 +11,25 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func DomainToChangeDetailsPb(objectDetail *domain.ObjectDetails) *object_pb.ObjectDetails {
|
func DomainToChangeDetailsPb(objectDetail *domain.ObjectDetails) *object_pb.ObjectDetails {
|
||||||
return &object_pb.ObjectDetails{
|
details := &object_pb.ObjectDetails{
|
||||||
Sequence: objectDetail.Sequence,
|
Sequence: objectDetail.Sequence,
|
||||||
ChangeDate: timestamppb.New(objectDetail.EventDate),
|
|
||||||
ResourceOwner: objectDetail.ResourceOwner,
|
ResourceOwner: objectDetail.ResourceOwner,
|
||||||
}
|
}
|
||||||
|
if !objectDetail.EventDate.IsZero() {
|
||||||
|
details.ChangeDate = timestamppb.New(objectDetail.EventDate)
|
||||||
|
}
|
||||||
|
return details
|
||||||
}
|
}
|
||||||
|
|
||||||
func DomainToAddDetailsPb(objectDetail *domain.ObjectDetails) *object_pb.ObjectDetails {
|
func DomainToAddDetailsPb(objectDetail *domain.ObjectDetails) *object_pb.ObjectDetails {
|
||||||
return &object_pb.ObjectDetails{
|
details := &object_pb.ObjectDetails{
|
||||||
Sequence: objectDetail.Sequence,
|
Sequence: objectDetail.Sequence,
|
||||||
CreationDate: timestamppb.New(objectDetail.EventDate),
|
|
||||||
ResourceOwner: objectDetail.ResourceOwner,
|
ResourceOwner: objectDetail.ResourceOwner,
|
||||||
}
|
}
|
||||||
|
if !objectDetail.EventDate.IsZero() {
|
||||||
|
details.CreationDate = timestamppb.New(objectDetail.EventDate)
|
||||||
|
}
|
||||||
|
return details
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToViewDetailsPb(
|
func ToViewDetailsPb(
|
||||||
@@ -32,12 +38,17 @@ func ToViewDetailsPb(
|
|||||||
changeDate time.Time,
|
changeDate time.Time,
|
||||||
resourceOwner string,
|
resourceOwner string,
|
||||||
) *object_pb.ObjectDetails {
|
) *object_pb.ObjectDetails {
|
||||||
return &object_pb.ObjectDetails{
|
details := &object_pb.ObjectDetails{
|
||||||
Sequence: sequence,
|
Sequence: sequence,
|
||||||
CreationDate: timestamppb.New(creationDate),
|
|
||||||
ChangeDate: timestamppb.New(changeDate),
|
|
||||||
ResourceOwner: resourceOwner,
|
ResourceOwner: resourceOwner,
|
||||||
}
|
}
|
||||||
|
if !creationDate.IsZero() {
|
||||||
|
details.CreationDate = timestamppb.New(creationDate)
|
||||||
|
}
|
||||||
|
if !changeDate.IsZero() {
|
||||||
|
details.ChangeDate = timestamppb.New(changeDate)
|
||||||
|
}
|
||||||
|
return details
|
||||||
}
|
}
|
||||||
|
|
||||||
func ChangeToDetailsPb(
|
func ChangeToDetailsPb(
|
||||||
@@ -45,11 +56,14 @@ func ChangeToDetailsPb(
|
|||||||
changeDate time.Time,
|
changeDate time.Time,
|
||||||
resourceOwner string,
|
resourceOwner string,
|
||||||
) *object_pb.ObjectDetails {
|
) *object_pb.ObjectDetails {
|
||||||
return &object_pb.ObjectDetails{
|
details := &object_pb.ObjectDetails{
|
||||||
Sequence: sequence,
|
Sequence: sequence,
|
||||||
ChangeDate: timestamppb.New(changeDate),
|
|
||||||
ResourceOwner: resourceOwner,
|
ResourceOwner: resourceOwner,
|
||||||
}
|
}
|
||||||
|
if !changeDate.IsZero() {
|
||||||
|
details.ChangeDate = timestamppb.New(changeDate)
|
||||||
|
}
|
||||||
|
return details
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddToDetailsPb(
|
func AddToDetailsPb(
|
||||||
@@ -57,11 +71,14 @@ func AddToDetailsPb(
|
|||||||
creationDate time.Time,
|
creationDate time.Time,
|
||||||
resourceOwner string,
|
resourceOwner string,
|
||||||
) *object_pb.ObjectDetails {
|
) *object_pb.ObjectDetails {
|
||||||
return &object_pb.ObjectDetails{
|
details := &object_pb.ObjectDetails{
|
||||||
Sequence: sequence,
|
Sequence: sequence,
|
||||||
CreationDate: timestamppb.New(creationDate),
|
|
||||||
ResourceOwner: resourceOwner,
|
ResourceOwner: resourceOwner,
|
||||||
}
|
}
|
||||||
|
if !creationDate.IsZero() {
|
||||||
|
details.CreationDate = timestamppb.New(creationDate)
|
||||||
|
}
|
||||||
|
return details
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToListDetails(
|
func ToListDetails(
|
||||||
|
Reference in New Issue
Block a user