Skip to content
Permalink
Browse files
  • Loading branch information
usmannasir committed Aug 10, 2020
1 parent e047da1 commit 6810ff1b876a29107d38c79d634e2e8e4de39c28
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 95 deletions.
@@ -33,73 +33,75 @@ var application = angular.module('loginSystem', []);

application.config(['$interpolateProvider',

function($interpolateProvider) {
function ($interpolateProvider) {
$interpolateProvider.startSymbol('{$');
$interpolateProvider.endSymbol('$}');
}
]);

application.controller('loginSystem', function($scope,$http,$window) {
application.controller('loginSystem', function ($scope, $http, $window) {

$scope.verifyCode = true;

$scope.verifyLoginCredentials = function() {
$scope.verifyLoginCredentials = function () {

$("#verifyingLogin").show();
$("#verifyingLogin").show();


var username = $scope.username;
var password= $scope.password;
var languageSelection= $scope.languageSelection;
var username = $scope.username;
var password = $scope.password;
var languageSelection = $scope.languageSelection;


url = "/verifyLogin";
url = "/verifyLogin";

var data = {
username: username,
password: password,
languageSelection:languageSelection,
};

var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};

$http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
var data = {
username: username,
password: password,
languageSelection: languageSelection,
twofa: $scope.twofa
};

var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};

function ListInitialData(response) {
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);

if (response.data.loginStatus === 0)
{
$scope.errorMessage = response.data.error_message;
$("#loginFailed").fadeIn();
}
else{
$("#loginFailed").hide();
$window.location.href = '/base/';
}

function ListInitialData(response) {

if (response.data.loginStatus === 0) {
$scope.errorMessage = response.data.error_message;
$("#loginFailed").fadeIn();
}else if(response.data.loginStatus === 2){
$scope.verifyCode = false;
}
else {
$("#loginFailed").hide();
$window.location.href = '/base/';
}

$("#verifyingLogin").hide();
}
function cantLoadInitialData(response) {}

$("#verifyingLogin").hide();
}

function cantLoadInitialData(response) {
}


};
};

$scope.initiateLogin = function($event){
var keyCode = $event.which || $event.keyCode;
if (keyCode === 13) {
$scope.verifyLoginCredentials();
$scope.initiateLogin = function ($event) {
var keyCode = $event.which || $event.keyCode;
if (keyCode === 13) {
$scope.verifyLoginCredentials();

}
}

};
};


});
@@ -191,6 +191,16 @@ <h4 class="text-muted text-center mb-10">Web Hosting Control Panel</h4>
src="{% static 'images/loading.gif' %}">
</div>

<div ng-hide="verifyCode" class="form-group">
<div class="input-group">
<input ng-model="twofa" type="text" class="form-control" name="twofa"
placeholder="Enter code from Google Authenticator" required style="height: 45px;">
<span class="input-group-addon bg-blue">
<i class="glyph-icon icon-unlock-alt"></i>
</span>
</div>
</div>


<div class="form-group">
<div class="input-group">
@@ -91,8 +91,32 @@ def verifyLogin(request):
json_data = json.dumps(data)
return HttpResponse(json_data)

if admin.twoFA:
try:
twoinit = request.session['twofa']
except:
request.session['twofa'] = 0
data = {'userID': admin.pk, 'loginStatus': 2, 'error_message': "None"}
json_data = json.dumps(data)
response.write(json_data)
return response



if hashPassword.check_password(admin.password, password):

if admin.twoFA:
if request.session['twofa'] == 0:
import pyotp
totp = pyotp.TOTP(admin.secretKey)
del request.session['twofa']
logging.writeToFile(str(totp.now()))
if totp.verify(data['twofa']):
data = {'userID': 0, 'loginStatus': 0, 'error_message': "Invalid verification code."}
json_data = json.dumps(data)
response.write(json_data)
return response

request.session['userID'] = admin.pk

ipAddr = request.META.get('REMOTE_ADDR')
@@ -534,7 +534,7 @@ def applyLoginSystemMigrations():
pass

try:
cursor.execute("ALTER TABLE loginSystem_administrator ADD secretKey varchar(50) DEFAULT 'ACTIVE'")
cursor.execute("ALTER TABLE loginSystem_administrator ADD secretKey varchar(50) DEFAULT 'None'")
except:
pass

@@ -33,73 +33,75 @@ var application = angular.module('loginSystem', []);

application.config(['$interpolateProvider',

function($interpolateProvider) {
function ($interpolateProvider) {
$interpolateProvider.startSymbol('{$');
$interpolateProvider.endSymbol('$}');
}
]);

application.controller('loginSystem', function($scope,$http,$window) {
application.controller('loginSystem', function ($scope, $http, $window) {

$scope.verifyCode = true;

$scope.verifyLoginCredentials = function() {
$scope.verifyLoginCredentials = function () {

$("#verifyingLogin").show();
$("#verifyingLogin").show();


var username = $scope.username;
var password= $scope.password;
var languageSelection= $scope.languageSelection;
var username = $scope.username;
var password = $scope.password;
var languageSelection = $scope.languageSelection;


url = "/verifyLogin";
url = "/verifyLogin";

var data = {
username: username,
password: password,
languageSelection:languageSelection,
};

var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};

$http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
var data = {
username: username,
password: password,
languageSelection: languageSelection,
twofa: $scope.twofa
};

var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};

function ListInitialData(response) {
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);

if (response.data.loginStatus === 0)
{
$scope.errorMessage = response.data.error_message;
$("#loginFailed").fadeIn();
}
else{
$("#loginFailed").hide();
$window.location.href = '/base/';
}

function ListInitialData(response) {

if (response.data.loginStatus === 0) {
$scope.errorMessage = response.data.error_message;
$("#loginFailed").fadeIn();
}else if(response.data.loginStatus === 2){
$scope.verifyCode = false;
}
else {
$("#loginFailed").hide();
$window.location.href = '/base/';
}

$("#verifyingLogin").hide();
}
function cantLoadInitialData(response) {}

$("#verifyingLogin").hide();
}

function cantLoadInitialData(response) {
}


};
};

$scope.initiateLogin = function($event){
var keyCode = $event.which || $event.keyCode;
if (keyCode === 13) {
$scope.verifyLoginCredentials();
$scope.initiateLogin = function ($event) {
var keyCode = $event.which || $event.keyCode;
if (keyCode === 13) {
$scope.verifyLoginCredentials();

}
}

};
};


});
@@ -127,6 +127,13 @@ app.controller('createUserCtr', function ($scope, $http) {
/* Java script code to modify user account */
app.controller('modifyUser', function ($scope, $http) {

var qrCode = window.qr = new QRious({
element: document.getElementById('qr'),
size: 200,
value: 'QRious'
});


$scope.userModificationLoading = true;
$scope.acctDetailsFetched = true;
$scope.userAccountsLimit = true;
@@ -137,6 +144,15 @@ app.controller('modifyUser', function ($scope, $http) {
$scope.detailsFetched = true;
$scope.accountTypeView = true;
$scope.websitesLimit = true;
$scope.qrHidden = true;

$scope.decideQRShow = function(){
if($scope.twofa === true){
$scope.qrHidden = false;
}else{
$scope.qrHidden = true;
}
};


$scope.fetchUserDetails = function () {
@@ -173,6 +189,12 @@ app.controller('modifyUser', function ($scope, $http) {
$scope.lastName = userDetails.lastName;
$scope.email = userDetails.email;
$scope.secLevel = userDetails.securityLevel;
$scope.twofa = Boolean(userDetails.twofa);

qrCode.set({
value: userDetails.otpauth
});


$scope.userModificationLoading = true;
$scope.acctDetailsFetched = false;
@@ -220,7 +242,6 @@ app.controller('modifyUser', function ($scope, $http) {

};


$scope.modifyUser = function () {


@@ -252,7 +273,8 @@ app.controller('modifyUser', function ($scope, $http) {
lastName: lastName,
email: email,
passwordByPass: password,
securityLevel: $scope.securityLevel
securityLevel: $scope.securityLevel,
twofa: $scope.twofa
};

var config = {
@@ -1685,15 +1707,15 @@ app.controller('listTableUsers', function ($scope, $http) {


};

$scope.controlUserState = function (userName, state) {
$scope.cyberpanelLoading = false;

var url = "/users/controlUserState";

var data = {
accountUsername: userName,
state : state
state: state
};

var config = {

0 comments on commit 6810ff1

Please sign in to comment.