resetPasswordCtrl.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. define([
  2. 'angular',
  3. ],
  4. function (angular) {
  5. 'use strict';
  6. var module = angular.module('grafana.controllers');
  7. module.controller('ResetPasswordCtrl', function($scope, contextSrv, backendSrv, $location) {
  8. contextSrv.sidemenu = false;
  9. $scope.formModel = {};
  10. $scope.mode = 'send';
  11. if ($location.search().code) {
  12. $scope.mode = 'reset';
  13. }
  14. $scope.sendResetEmail = function() {
  15. if (!$scope.sendResetForm.$valid) {
  16. return;
  17. }
  18. backendSrv.post('/api/user/password/send-reset-email', $scope.formModel).then(function() {
  19. $scope.mode = 'email-sent';
  20. });
  21. };
  22. $scope.submitReset = function() {
  23. if (!$scope.resetForm.$valid) { return; }
  24. if ($scope.formModel.newPassword !== $scope.formModel.confirmPassword) {
  25. $scope.appEvent('alert-warning', ['New passwords do not match', '']);
  26. return;
  27. }
  28. backendSrv.post('/api/user/password/send-reset-email', $scope.formModel).then(function() {
  29. $location.path('login');
  30. });
  31. };
  32. });
  33. });