change_password_ctrl.js 852 B

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