Allow using password param to connect

This commit is contained in:
Garry Newman
2016-04-12 10:49:34 +01:00
parent 2950bd483a
commit c95ca0445a
+21 -1
View File
@@ -1,12 +1,14 @@
app.controller( 'ConnectionController', ConnectionController ); app.controller( 'ConnectionController', ConnectionController );
function ConnectionController( $scope, rconService, $routeParams, $timeout ) function ConnectionController( $scope, rconService, $routeParams, $timeout, $location )
{ {
$scope.Address = ""; $scope.Address = "";
$scope.Password = ""; $scope.Password = "";
$scope.SaveConnection = true; $scope.SaveConnection = true;
console.log( $location.search );
if ( localStorage.previousConnections != null ) if ( localStorage.previousConnections != null )
$scope.PreviousConnects = angular.fromJson( localStorage.previousConnections ); $scope.PreviousConnects = angular.fromJson( localStorage.previousConnections );
@@ -53,13 +55,31 @@ function ConnectionController( $scope, rconService, $routeParams, $timeout )
{ {
$scope.Address = $routeParams.address; $scope.Address = $routeParams.address;
//
// If a password was passed as a search param, use that
//
var pw = $location.search().password;
if ( pw )
{
$scope.Password = pw;
$location.search( "password", null );
}
if ( $scope.Address != null ) if ( $scope.Address != null )
{ {
// If we have a password (passed as a search param) then connect using that
if ( $scope.Password != "" )
{
$scope.Connect();
return;
}
var foundAddress = Enumerable.From( $scope.PreviousConnects ).Where( function ( x ) { return x.Address == $scope.Address } ).First(); var foundAddress = Enumerable.From( $scope.PreviousConnects ).Where( function ( x ) { return x.Address == $scope.Address } ).First();
if ( foundAddress != null ) if ( foundAddress != null )
{ {
$scope.ConnectTo( foundAddress ); $scope.ConnectTo( foundAddress );
} }
} }
}, 20 ); }, 20 );