Update header.php
This commit is contained in:
parent
c5dec5a0b9
commit
9c3dd69854
@ -3,7 +3,6 @@
|
|||||||
// Turn off error reporting
|
// Turn off error reporting
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
@ini_set('display_errors', 0);
|
@ini_set('display_errors', 0);
|
||||||
session_start();
|
|
||||||
|
|
||||||
$tradersList = array();
|
$tradersList = array();
|
||||||
$buy_list = array();
|
$buy_list = array();
|
||||||
@ -13,7 +12,8 @@ $validate_user = null;
|
|||||||
if (isset($UserClass)) {
|
if (isset($UserClass)) {
|
||||||
if (isset($_SESSION['flo_id'])):
|
if (isset($_SESSION['flo_id'])):
|
||||||
// check if user already registered
|
// check if user already registered
|
||||||
$validate_user = $UserClass->doInitialUserHandling($_SESSION['flo_id']);
|
$validate_user = $UserClass->doInitialUserHandling($flo_id);
|
||||||
|
|
||||||
if($validate_user == "" || $validate_user == false) {
|
if($validate_user == "" || $validate_user == false) {
|
||||||
redirect_to('index.php');
|
redirect_to('index.php');
|
||||||
}
|
}
|
||||||
@ -95,51 +95,58 @@ $type = isset($_GET['type']) ? trim($_GET['type']) : 'danger';
|
|||||||
<h2 class="text-center">Login using FLO Private Key </h2>
|
<h2 class="text-center">Login using FLO Private Key </h2>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="col-lg-12 lazy-form">
|
<div class="col-lg-12 lazy-form">
|
||||||
<label for="key_flo">Enter your FLO Private Key</label>
|
<label for="key_flo" id="loginMessage">Enter your FLO Private Key</label>
|
||||||
<input type="text" name="key_flo" id="key_flo" style="color:initial">
|
<input type="text" name="key_flo" id="key_flo" style="color:initial">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<input type="submit" id="key_flo_submit" class="btn btn--block btn--facebook flo_log_in" style="width: 100%;" value="Enter Key">
|
<input type="submit" id="key_flo_submit" class="btn btn--block btn--facebook flo_log_in" style="width: 100%;" value="Enter Key">
|
||||||
</div>
|
</div>
|
||||||
<a href="logout.php" id="to_logout_fields" style="visibility: hidden;">
|
<a href="logout.php" id="to_logout_fields" style="visibility: hidden">
|
||||||
<div class="btn btn--facebook ">
|
<div class="btn btn--facebook ">
|
||||||
Log Out
|
Log Out
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
// Need to handle authentication fail case .. its easy
|
// Need to handle authentication fail case .. its easy
|
||||||
|
|
||||||
function ajax_authentication(floID1,floPubKey1,message1,signDataWithFlo1) {
|
function ajax_authentication(floID,floPubKey,message,signDataWithFlo) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:'post',
|
method:'post',
|
||||||
url:'ajax/authenticateMe.php',
|
url:'ajax/authenticateMe.php',
|
||||||
data: { floID: floID1,floPubKey:floPubKey1,message:message1,signDataWithFlo:signDataWithFlo1},
|
data: { floID: floID,floPubKey:floPubKey,message:message,signDataWithFlo:signDataWithFlo},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
}
|
}
|
||||||
}).error(function(xhr, status, error) {
|
}).error(function(xhr, status, error) {
|
||||||
console.log(xhr.responseText);
|
console.log(xhr.responseText);
|
||||||
|
document.getElementById("loginMessage").innerHTML = xhr.responseText;
|
||||||
|
document.getElementById("loginMessage").style.color = "red";
|
||||||
}).success(function(data) {
|
}).success(function(data) {
|
||||||
|
|
||||||
var IS_JSON = true;
|
var IS_JSON = true;
|
||||||
try {
|
try {
|
||||||
var d = jQuery.parseJSON(data);
|
var d = jQuery.parseJSON(data);
|
||||||
console.log(d.message);
|
console.log(d.message);
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
IS_JSON = false;
|
IS_JSON = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IS_JSON) {
|
if(IS_JSON) {
|
||||||
if(d.error == false) {
|
if(d.error == false) {
|
||||||
document.getElementById("to_login_fields").style.visibility = "hidden";
|
document.getElementById("to_login_fields").style.visibility = "hidden";
|
||||||
document.getElementById("to_logout_fields").style.visibility = "visible";
|
document.getElementById("to_logout_fields").style.visibility = "visible";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
document.getElementById("loginMessage").innerHTML = d.message;
|
||||||
|
document.getElementById("loginMessage").style.color = "red";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -150,11 +157,18 @@ function ajax_authentication(floID1,floPubKey1,message1,signDataWithFlo1) {
|
|||||||
let floPrivKey = document.getElementById("key_flo").value;
|
let floPrivKey = document.getElementById("key_flo").value;
|
||||||
let floPubKey = floCrypto.getPubKeyHex(floPrivKey);
|
let floPubKey = floCrypto.getPubKeyHex(floPrivKey);
|
||||||
let floID = floCrypto.getFloID(floPubKey);
|
let floID = floCrypto.getFloID(floPubKey);
|
||||||
let message = <?php $_SESSION['session_id'] ?>;
|
|
||||||
|
if (floID != null) {
|
||||||
|
let message ="<?php echo $_SESSION['session_id'];?>";
|
||||||
let signDataWithFlo = floCrypto.signData(message, floPrivKey);
|
let signDataWithFlo = floCrypto.signData(message, floPrivKey);
|
||||||
delete floPrivKey;
|
delete floPrivKey;
|
||||||
ajax_authentication(floID,floPubKey,message,signDataWithFlo);
|
ajax_authentication(floID,floPubKey,message,signDataWithFlo);
|
||||||
|
} else {
|
||||||
|
var displayMessage = "Private Key is invalid";
|
||||||
|
console.log(displayMessage);
|
||||||
|
document.getElementById("loginMessage").innerHTML = displayMessage;
|
||||||
|
document.getElementById("loginMessage").style.color = "red";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user