Skip to content

Commit

Permalink
#1067 Fix the error where migration page is replaced by login page
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Aug 20, 2019
1 parent accc951 commit 0090706
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object Dependencies {

val reflections = "org.reflections" % "reflections" % "0.9.11"
val zip4j = "net.lingala.zip4j" % "zip4j" % "1.3.2"
val elastic4play = "org.thehive-project" %% "elastic4play" % "1.11.4"
val elastic4play = "org.thehive-project" %% "elastic4play" % "1.11.5-SNAPSHOT"
val akkaCluster = "com.typesafe.akka" %% "akka-cluster" % "2.5.19"
val akkaClusterTools = "com.typesafe.akka" %% "akka-cluster-tools" % "2.5.19"
}
Expand Down
7 changes: 5 additions & 2 deletions thehive-backend/app/controllers/StreamCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import services.StreamActor
import services.StreamActor.StreamMessages

import org.elastic4play.controllers._
import org.elastic4play.services.{AuxSrv, EventSrv, MigrationSrv}
import org.elastic4play.services.{ AuxSrv, EventSrv, MigrationSrv, UserSrv }
import org.elastic4play.Timed

@Singleton
Expand All @@ -33,6 +33,7 @@ class StreamCtrl(
authenticated: Authenticated,
renderer: Renderer,
eventSrv: EventSrv,
userSrv: UserSrv,
auxSrv: AuxSrv,
migrationSrv: MigrationSrv,
components: ControllerComponents,
Expand All @@ -46,6 +47,7 @@ class StreamCtrl(
authenticated: Authenticated,
renderer: Renderer,
eventSrv: EventSrv,
userSrv: UserSrv,
auxSrv: AuxSrv,
migrationSrv: MigrationSrv,
components: ControllerComponents,
Expand All @@ -58,6 +60,7 @@ class StreamCtrl(
authenticated,
renderer,
eventSrv,
userSrv,
auxSrv,
migrationSrv,
components,
Expand Down Expand Up @@ -96,7 +99,7 @@ class StreamCtrl(
Future.successful(BadRequest("Invalid stream id"))
} else {
val futureStatus = authenticated.expirationStatus(request) match {
case ExpirationError if !migrationSrv.isMigrating authenticated.getFromApiKey(request).map(_ OK)
case ExpirationError if !migrationSrv.isMigrating userSrv.getInitialUser(request).recoverWith { case _ => authenticated.getFromApiKey(request)}.map(_ OK)
case _: ExpirationWarning Future.successful(220)
case _ Future.successful(OK)
}
Expand Down
21 changes: 12 additions & 9 deletions ui/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ angular.module('thehive', [
})
.config(function($compileProvider) {
'use strict';
$compileProvider.debugInfoEnabled(false);
$compileProvider.debugInfoEnabled(false);
})
.config(function($stateProvider, $urlRouterProvider) {
'use strict';
Expand Down Expand Up @@ -80,15 +80,17 @@ angular.module('thehive', [
templateUrl: 'views/app.html',
controller: 'RootCtrl',
resolve: {
currentUser: function($q, $state, AuthenticationSrv) {
currentUser: function($q, $state, AuthenticationSrv, NotificationSrv) {
var deferred = $q.defer();

AuthenticationSrv.current()
.then(function(userData) {
return deferred.resolve(userData);
})
.catch( function(err) {
return deferred.resolve(err.status === 520 ? err.status : null);
NotificationSrv.error('App', err.data, err.status);
return deferred.reject(err);
//return deferred.resolve(err.status === 520 ? err.status : null);
});

return deferred.promise;
Expand Down Expand Up @@ -148,19 +150,20 @@ angular.module('thehive', [
controller: 'SettingsCtrl',
title: 'Personal settings',
resolve: {
currentUser: function($q, $state, $timeout, AuthenticationSrv) {
currentUser: function($q, $state, $timeout, AuthenticationSrv, NotificationSrv) {
var deferred = $q.defer();

AuthenticationSrv.current()
.then(function(userData) {
return deferred.resolve(userData);
})
.catch( function(/*err*/) {
$timeout(function() {
$state.go('login');
});
.catch( function(err) {
NotificationSrv.error('SettingsCtrl', err.data, err.status);
// $timeout(function() {
// $state.go('login');
// });

return deferred.reject();
return deferred.reject(err);
});

return deferred.promise;
Expand Down

0 comments on commit 0090706

Please sign in to comment.