random-change-password.controller.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Password Management Servlets (PWM)
  3. * http://www.pwm-project.org
  4. *
  5. * Copyright (c) 2006-2009 Novell, Inc.
  6. * Copyright (c) 2009-2021 The PWM Project
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. import {IHelpDeskService, ISuccessResponse} from '../../services/helpdesk.service';
  21. import {IChangePasswordSuccess} from './success-change-password.controller';
  22. export default class RandomChangePasswordController {
  23. static $inject = [
  24. 'HelpDeskService',
  25. 'IasDialogService',
  26. 'personUserKey',
  27. 'translateFilter'
  28. ];
  29. constructor(private HelpDeskService: IHelpDeskService,
  30. private IasDialogService: any,
  31. private personUserKey: string,
  32. private translateFilter: (id: string) => string) {
  33. }
  34. confirmSetRandomPassword() {
  35. this.HelpDeskService.setPassword(this.personUserKey, true)
  36. .then((result: ISuccessResponse) => {
  37. // Send the password and success message to the parent element via the close() method.
  38. let chosenPassword = '[' + this.translateFilter('Display_Random') + ']';
  39. let data: IChangePasswordSuccess = { password: chosenPassword, successMessage: result.successMessage };
  40. this.IasDialogService.close(data);
  41. });
  42. }
  43. }