Commit 7b291334 authored by Kgneo's avatar Kgneo

Merged branch development into kgougle

parents 2a6460e5 e7799287
......@@ -4827,9 +4827,9 @@ function initKInterface(params){ console.log("initKInterface");
});
$(".logout").click(function(){ console.log("YOU ARE GOING TO LOGOUT");
$.cookie("email", "null", { expires: 180, path : "/" });
$.cookie("pwd", "null", { expires: 180, path : "/" });
$(".logout").click(function(){
$.cookie("lyame", "null", { expires: 180, path : "/" });
$.cookie("drowsp", "null", { expires: 180, path : "/" });
$.cookie("remember", false, { expires: 180, path : "/" });
window.location.href=baseUrl+"/co2/person/logout";
});
......
......@@ -86,6 +86,7 @@ var Login = function() {
}
});
};
var runLoginValidator = function() {
var form = $('.form-login');
var loginBtn = null;
......@@ -126,8 +127,10 @@ var Login = function() {
if(data.result){
if($("#remember").prop("checked")){
$.cookie("email", $("#email-login").val(), { expires: 180, path : "/" });
$.cookie("pwd", $("#password-login").val(), { expires: 180, path : "/" });
var pwdEncrypt = encryptPwd($("#password-login").val());
var emailEncrypt = encryptPwd($("#email-login").val());
$.cookie("lyame", emailEncrypt, { expires: 180, path : "/" });
$.cookie("drowsp", pwdEncrypt, { expires: 180, path : "/" });
$.cookie("remember", $("#remember").prop("checked"), { expires: 180, path : "/" });
}
......@@ -545,4 +548,27 @@ function initRegister() {
$(".form-register #password3").val("");
$(".form-register #passwordAgain").val("");
$(".form-register #inviteCode").val("");
}
\ No newline at end of file
}
var CryptoJSAesJson = {
stringify: function (cipherParams) {
var j = {ct: cipherParams.ciphertext.toString(CryptoJS.enc.Base64)};
if (cipherParams.iv) j.iv = cipherParams.iv.toString();
if (cipherParams.salt) j.s = cipherParams.salt.toString();
return JSON.stringify(j);
},
parse: function (jsonStr) {
var j = JSON.parse(jsonStr);
var cipherParams = CryptoJS.lib.CipherParams.create({ciphertext: CryptoJS.enc.Base64.parse(j.ct)});
if (j.iv) cipherParams.iv = CryptoJS.enc.Hex.parse(j.iv);
if (j.s) cipherParams.salt = CryptoJS.enc.Hex.parse(j.s);
return cipherParams;
}
};
function encryptPwd(pwd){
var secureKey = 'JbQmfH"h^W7q86JU1V(<64aEv';
var encrypted = CryptoJS.AES.encrypt(JSON.stringify(pwd), secureKey, {format: CryptoJSAesJson});
return encrypted.toString();
}
......@@ -49,7 +49,7 @@
"subdomain" : "web",
"subdomainName" : "web",
"hash" : "#app.web",
"icon" : "search",
"icon" : "globe",
"mainTitle" : "Moteur de recherche",
"placeholderMainSearch" : "Que recherchez-vous ?"},
......
......@@ -25,10 +25,11 @@ on garde les librairies specifique au module dans le module
if(isset( Yii::app()->request->cookies['remember'] ) && Yii::app()->request->cookies['remember']->value == "true" &&
isset( Yii::app()->request->cookies['email'] ) &&
isset( Yii::app()->request->cookies['pwd'] ) && @Yii::app()->request->cookies['pwd']->value != "null"){
$res = Person::login(Yii::app()->request->cookies['email']->value, Yii::app()->request->cookies['pwd']->value, false);
//var_dump(Yii::app()->request->cookies['email']->value); exit;
isset( Yii::app()->request->cookies['lyame'] ) &&
isset( Yii::app()->request->cookies['drowsp'] ) && @Yii::app()->request->cookies['drowsp']->value != "null"){
$pwdDecrypt = pwdDecrypt(Yii::app()->request->cookies['drowsp']->value);
$emailDecrypt = pwdDecrypt(Yii::app()->request->cookies['lyame']->value);
$res = Person::login($emailDecrypt, $pwdDecrypt, false);
}
function random_pic()
......@@ -43,6 +44,34 @@ on garde les librairies specifique au module dans le module
} else
return array();
}
function pwdDecrypt($jsonString){ //return $jsonString;
$passphrase = 'JbQmfH"h^W7q86JU1V(<64aEv';
$jsondata = json_decode($jsonString, true);
try {
$salt = hex2bin($jsondata["s"]);
$iv = hex2bin($jsondata["iv"]);
} catch(Exception $e) { return null; }
$ct = base64_decode($jsondata["ct"]);
$concatedPassphrase = $passphrase.$salt;
$md5 = array();
$md5[0] = md5($concatedPassphrase, true);
$result = $md5[0];
for ($i = 1; $i < 3; $i++) {
$md5[$i] = md5($md5[$i - 1].$concatedPassphrase, true);
$result .= $md5[$i];
}
$key = substr($result, 0, 32);
//var_dump($iv); exit;
$data = openssl_decrypt($ct, 'aes-256-cbc', $key, true, $iv);
return json_decode($data, true);
}
?>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment