Worked on login remember cookie and redirect after login

pull/1442/head
Torkel Ödegaard 10 years ago
parent 11b74baf79
commit 4572747bd6
  1. 12
      src/app/controllers/loginCtrl.js
  2. 4
      src/app/partials/login.html

@ -7,7 +7,7 @@ function (angular, config) {
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
module.controller('LoginCtrl', function($scope, backendSrv, $location, $routeParams, alertSrv) { module.controller('LoginCtrl', function($scope, backendSrv, $location, $routeParams) {
$scope.formModel = { $scope.formModel = {
user: '', user: '',
@ -82,7 +82,6 @@ function (angular, config) {
$scope.logout = function() { $scope.logout = function() {
backendSrv.post('/logout').then(function() { backendSrv.post('/logout').then(function() {
alertSrv.set('Logged out!', '', 'success', 3000);
$scope.appEvent('logged-out'); $scope.appEvent('logged-out');
$location.search({}); $location.search({});
}); });
@ -95,8 +94,13 @@ function (angular, config) {
return; return;
} }
backendSrv.post('/login', $scope.formModel).then(function() { backendSrv.post('/login', $scope.formModel).then(function(result) {
window.location.href = config.appSubUrl + '/'; if (result.redirectUrl) {
console.log(result);
window.location.href = result.redirectUrl;
} else {
window.location.href = config.appSubUrl + '/';
}
}); });
}; };

@ -23,7 +23,7 @@
<strong>User</strong> <strong>User</strong>
</li> </li>
<li> <li>
<input type="text" class="tight-form-input last" ng-model='formModel.user' placeholder="email or username" style="width: 246px"> <input type="text" name="username" class="tight-form-input last" ng-model='formModel.user' placeholder="email or username" style="width: 246px">
</li> </li>
</ul> </ul>
<div class="clearfix"></div> <div class="clearfix"></div>
@ -34,7 +34,7 @@
<strong>Password</strong> <strong>Password</strong>
</li> </li>
<li> <li>
<input type="password" class="tight-form-input last" required ng-model="formModel.password" id="inputPassword" style="width: 246px" placeholder="password"> <input type="password" name="password" class="tight-form-input last" required ng-model="formModel.password" id="inputPassword" style="width: 246px" placeholder="password">
</li> </li>
</ul> </ul>
<div class="clearfix"></div> <div class="clearfix"></div>

Loading…
Cancel
Save