change_password_ctrl.js 824 B

12345678910111213141516171819202122232425262728293031
  1. define([
  2. 'angular',
  3. 'app/core/config',
  4. ],
  5. function (angular, config) {
  6. 'use strict';
  7. var module = angular.module('grafana.controllers');
  8. module.controller('ChangePasswordCtrl', function($scope, backendSrv, $location, navModelSrv) {
  9. $scope.command = {};
  10. $scope.authProxyEnabled = config.authProxyEnabled;
  11. $scope.ldapEnabled = config.ldapEnabled;
  12. $scope.navModel = navModelSrv.getProfileNav();
  13. $scope.changePassword = function() {
  14. if (!$scope.userForm.$valid) { return; }
  15. if ($scope.command.newPassword !== $scope.command.confirmNew) {
  16. $scope.appEvent('alert-warning', ['New passwords do not match', '']);
  17. return;
  18. }
  19. backendSrv.put('/api/user/password', $scope.command).then(function() {
  20. $location.path("profile");
  21. });
  22. };
  23. });
  24. });