2015-06-05 04:44:52 -05:00
|
|
|
define([
|
|
|
|
'angular',
|
|
|
|
],
|
2015-06-08 03:57:01 -05:00
|
|
|
function (angular) {
|
2015-06-05 04:44:52 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var module = angular.module('grafana.controllers');
|
|
|
|
|
2015-06-08 03:57:01 -05:00
|
|
|
module.controller('ResetPasswordCtrl', function($scope, contextSrv, backendSrv, $location) {
|
2015-06-05 04:44:52 -05:00
|
|
|
|
|
|
|
contextSrv.sidemenu = false;
|
|
|
|
$scope.formModel = {};
|
2015-06-08 03:57:01 -05:00
|
|
|
$scope.mode = 'send';
|
|
|
|
|
2015-06-08 06:39:02 -05:00
|
|
|
var params = $location.search();
|
|
|
|
if (params.code) {
|
2015-06-08 03:57:01 -05:00
|
|
|
$scope.mode = 'reset';
|
2015-06-08 06:39:02 -05:00
|
|
|
$scope.formModel.code = params.code;
|
2015-06-08 03:57:01 -05:00
|
|
|
}
|
2015-06-05 04:44:52 -05:00
|
|
|
|
|
|
|
$scope.sendResetEmail = function() {
|
2015-06-08 03:57:01 -05:00
|
|
|
if (!$scope.sendResetForm.$valid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
backendSrv.post('/api/user/password/send-reset-email', $scope.formModel).then(function() {
|
|
|
|
$scope.mode = 'email-sent';
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.submitReset = function() {
|
|
|
|
if (!$scope.resetForm.$valid) { return; }
|
|
|
|
|
|
|
|
if ($scope.formModel.newPassword !== $scope.formModel.confirmPassword) {
|
|
|
|
$scope.appEvent('alert-warning', ['New passwords do not match', '']);
|
2015-06-05 04:44:52 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-08 06:39:02 -05:00
|
|
|
backendSrv.post('/api/user/password/reset', $scope.formModel).then(function() {
|
2015-06-08 03:57:01 -05:00
|
|
|
$location.path('login');
|
2015-06-05 04:44:52 -05:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|