Worked on login remember cookie and redirect after login
This commit is contained in:
@@ -7,7 +7,7 @@ function (angular, config) {
|
||||
|
||||
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 = {
|
||||
user: '',
|
||||
@@ -82,7 +82,6 @@ function (angular, config) {
|
||||
|
||||
$scope.logout = function() {
|
||||
backendSrv.post('/logout').then(function() {
|
||||
alertSrv.set('Logged out!', '', 'success', 3000);
|
||||
$scope.appEvent('logged-out');
|
||||
$location.search({});
|
||||
});
|
||||
@@ -95,8 +94,13 @@ function (angular, config) {
|
||||
return;
|
||||
}
|
||||
|
||||
backendSrv.post('/login', $scope.formModel).then(function() {
|
||||
window.location.href = config.appSubUrl + '/';
|
||||
backendSrv.post('/login', $scope.formModel).then(function(result) {
|
||||
if (result.redirectUrl) {
|
||||
console.log(result);
|
||||
window.location.href = result.redirectUrl;
|
||||
} else {
|
||||
window.location.href = config.appSubUrl + '/';
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<strong>User</strong>
|
||||
</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>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
@@ -34,7 +34,7 @@
|
||||
<strong>Password</strong>
|
||||
</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>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
Reference in New Issue
Block a user