change_password_ctrl.js 760 B

123456789101112131415161718192021222324252627282930
  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) {
  9. $scope.command = {};
  10. $scope.authProxyEnabled = config.authProxyEnabled;
  11. $scope.ldapEnabled = config.ldapEnabled;
  12. $scope.changePassword = function() {
  13. if (!$scope.userForm.$valid) { return; }
  14. if ($scope.command.newPassword !== $scope.command.confirmNew) {
  15. $scope.appEvent('alert-warning', ['New passwords do not match', '']);
  16. return;
  17. }
  18. backendSrv.put('/api/user/password', $scope.command).then(function() {
  19. $location.path("profile");
  20. });
  21. };
  22. });
  23. });