diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2018-10-06 13:54:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-11 09:26:29 +0100 |
commit | 328c78bc4a570a9aceaaa1a2124bacd4a0e8d295 (patch) | |
tree | 7f07a427828fb5540dfe7e6bed372e846d587b86 /client/src/app/+admin/users/user-edit/user-update.component.ts | |
parent | c7ca4c8be781753f86d806015b182f1ee5443fcf (diff) | |
download | PeerTube-328c78bc4a570a9aceaaa1a2124bacd4a0e8d295.tar.gz PeerTube-328c78bc4a570a9aceaaa1a2124bacd4a0e8d295.tar.zst PeerTube-328c78bc4a570a9aceaaa1a2124bacd4a0e8d295.zip |
allow administration to change/reset a user's password
Diffstat (limited to 'client/src/app/+admin/users/user-edit/user-update.component.ts')
-rw-r--r-- | client/src/app/+admin/users/user-edit/user-update.component.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts index 61e641823..cb74897d0 100644 --- a/client/src/app/+admin/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/users/user-edit/user-update.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit, Input } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { Subscription } from 'rxjs' | 3 | import { Subscription } from 'rxjs' |
4 | import { Notifier } from '@app/core' | 4 | import { Notifier } from '@app/core' |
@@ -19,9 +19,12 @@ import { UserService } from '@app/shared' | |||
19 | export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | 19 | export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { |
20 | error: string | 20 | error: string |
21 | userId: number | 21 | userId: number |
22 | userEmail: string | ||
22 | username: string | 23 | username: string |
24 | isAdministration = false | ||
23 | 25 | ||
24 | private paramsSub: Subscription | 26 | private paramsSub: Subscription |
27 | private isAdministrationSub: Subscription | ||
25 | 28 | ||
26 | constructor ( | 29 | constructor ( |
27 | protected formValidatorService: FormValidatorService, | 30 | protected formValidatorService: FormValidatorService, |
@@ -56,10 +59,15 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
56 | err => this.error = err.message | 59 | err => this.error = err.message |
57 | ) | 60 | ) |
58 | }) | 61 | }) |
62 | |||
63 | this.isAdministrationSub = this.route.data.subscribe(data => { | ||
64 | if (data.isAdministration) this.isAdministration = data.isAdministration | ||
65 | }) | ||
59 | } | 66 | } |
60 | 67 | ||
61 | ngOnDestroy () { | 68 | ngOnDestroy () { |
62 | this.paramsSub.unsubscribe() | 69 | this.paramsSub.unsubscribe() |
70 | this.isAdministrationSub.unsubscribe() | ||
63 | } | 71 | } |
64 | 72 | ||
65 | formValidated () { | 73 | formValidated () { |
@@ -89,9 +97,23 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
89 | return this.i18n('Update user') | 97 | return this.i18n('Update user') |
90 | } | 98 | } |
91 | 99 | ||
100 | resetPassword () { | ||
101 | this.userService.askResetPassword(this.userEmail).subscribe( | ||
102 | () => { | ||
103 | this.notificationsService.success( | ||
104 | this.i18n('Success'), | ||
105 | this.i18n('An email asking for password reset has been sent to {{username}}.', { username: this.username }) | ||
106 | ) | ||
107 | }, | ||
108 | |||
109 | err => this.error = err.message | ||
110 | ) | ||
111 | } | ||
112 | |||
92 | private onUserFetched (userJson: User) { | 113 | private onUserFetched (userJson: User) { |
93 | this.userId = userJson.id | 114 | this.userId = userJson.id |
94 | this.username = userJson.username | 115 | this.username = userJson.username |
116 | this.userEmail = userJson.email | ||
95 | 117 | ||
96 | this.form.patchValue({ | 118 | this.form.patchValue({ |
97 | email: userJson.email, | 119 | email: userJson.email, |