committed by
GitHub
39 changed files with 473 additions and 3 deletions
@ -0,0 +1,19 @@ |
|||
/** |
|||
* Copyright © 2016-2026 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data; |
|||
|
|||
public record UserPasswordResetLink(String value, long ttlMs) { |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2026 The Thingsboard Authors |
|||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); |
|||
you may not use this file except in compliance with the License. |
|||
You may obtain a copy of the License at |
|||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 |
|||
|
|||
Unless required by applicable law or agreed to in writing, software |
|||
distributed under the License is distributed on an "AS IS" BASIS, |
|||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
See the License for the specific language governing permissions and |
|||
limitations under the License. |
|||
|
|||
--> |
|||
<form style="min-width: 400px; position: relative;"> |
|||
<mat-toolbar color="primary"> |
|||
<h2 translate>user.password-reset-link</h2> |
|||
<span class="flex-1"></span> |
|||
<button mat-icon-button |
|||
(click)="close()" |
|||
type="button"> |
|||
<mat-icon class="material-icons">close</mat-icon> |
|||
</button> |
|||
</mat-toolbar> |
|||
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async"> |
|||
</mat-progress-bar> |
|||
<div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div> |
|||
<div mat-dialog-content tb-toast toastTarget="passwordResetLinkDialogContent"> |
|||
<div class="mat-content flex flex-col"> |
|||
<span [innerHTML]="'user.password-reset-link-text' | translate: {passwordResetLink: passwordResetLink, passwordResetLinkTtl: passwordResetLinkTtl}"></span> |
|||
<div class="flex flex-row items-center justify-start"> |
|||
<pre class="tb-highlight flex-1"><code>{{ passwordResetLink }}</code></pre> |
|||
<button mat-icon-button |
|||
color="primary" |
|||
ngxClipboard |
|||
cbContent="{{ passwordResetLink }}" |
|||
(cbOnSuccess)="onPasswordResetLinkCopied()" |
|||
matTooltip="{{ 'user.copy-password-reset-link' | translate }}" |
|||
matTooltipPosition="above"> |
|||
<mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon> |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div mat-dialog-actions class="flex items-center justify-end"> |
|||
<button mat-button color="primary" |
|||
type="button" |
|||
cdkFocusInitial |
|||
[disabled]="(isLoading$ | async)" |
|||
(click)="close()"> |
|||
{{ 'action.ok' | translate }} |
|||
</button> |
|||
</div> |
|||
</form> |
|||
@ -0,0 +1,69 @@ |
|||
///
|
|||
/// Copyright © 2016-2026 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { Component, Inject } from '@angular/core'; |
|||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { TranslateService } from '@ngx-translate/core'; |
|||
import { ActionNotificationShow } from '@core/notification/notification.actions'; |
|||
import { DialogComponent } from '@shared/components/dialog.component'; |
|||
import { Router } from '@angular/router'; |
|||
import { PasswordResetLinkInfo } from '@shared/models/user.model'; |
|||
import { MillisecondsToTimeStringPipe } from '@shared/pipe/milliseconds-to-time-string.pipe'; |
|||
|
|||
export interface PasswordResetLinkDialogData { |
|||
passwordResetLinkInfo: PasswordResetLinkInfo; |
|||
} |
|||
|
|||
@Component({ |
|||
selector: 'tb-password-reset-link-dialog', |
|||
templateUrl: './password-reset-link-dialog.component.html', |
|||
standalone: false |
|||
}) |
|||
export class PasswordResetLinkDialogComponent extends DialogComponent<PasswordResetLinkDialogComponent, void> { |
|||
|
|||
passwordResetLink: string; |
|||
passwordResetLinkTtl: string; |
|||
|
|||
constructor(protected store: Store<AppState>, |
|||
protected router: Router, |
|||
@Inject(MAT_DIALOG_DATA) public data: PasswordResetLinkDialogData, |
|||
public dialogRef: MatDialogRef<PasswordResetLinkDialogComponent, void>, |
|||
private translate: TranslateService, |
|||
private millisecondsToTimeStringPipe: MillisecondsToTimeStringPipe) { |
|||
super(store, router, dialogRef); |
|||
this.passwordResetLink = this.data.passwordResetLinkInfo.value; |
|||
this.passwordResetLinkTtl = this.millisecondsToTimeStringPipe.transform(this.data.passwordResetLinkInfo.ttlMs); |
|||
} |
|||
|
|||
close(): void { |
|||
this.dialogRef.close(); |
|||
} |
|||
|
|||
onPasswordResetLinkCopied() { |
|||
this.store.dispatch(new ActionNotificationShow( |
|||
{ |
|||
message: this.translate.instant('user.password-reset-link-copied-message'), |
|||
type: 'success', |
|||
target: 'passwordResetLinkDialogContent', |
|||
duration: 1200, |
|||
verticalPosition: 'bottom', |
|||
horizontalPosition: 'left' |
|||
})); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue