mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Resolve #713
This commit is contained in:
parent
b89d194863
commit
4085f58b4e
2 changed files with 19 additions and 4 deletions
13
dev/boot.js
13
dev/boot.js
|
|
@ -31,6 +31,19 @@ const
|
||||||
navigator.cookieEnabled || redirect('NoCookie');
|
navigator.cookieEnabled || redirect('NoCookie');
|
||||||
[].flat || redirect('BadBrowser');
|
[].flat || redirect('BadBrowser');
|
||||||
|
|
||||||
|
try {
|
||||||
|
let smctoken = localStorage.getItem('smctoken');
|
||||||
|
if (!smctoken) {
|
||||||
|
let data = new Uint8Array(16);
|
||||||
|
crypto.getRandomValues(data);
|
||||||
|
smctoken = btoa(String.fromCharCode(...data));
|
||||||
|
localStorage.setItem('smctoken', smctoken);
|
||||||
|
}
|
||||||
|
document.cookie = 'smctoken='+encodeURIComponent(smctoken)+"; path=/; samesite=strict";
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
let RL_APP_DATA = {};
|
let RL_APP_DATA = {};
|
||||||
|
|
||||||
doc.documentElement.classList.toggle('rl-mobile', 'mobile' === layout[2] || (!layout && 1000 > innerWidth));
|
doc.documentElement.classList.toggle('rl-mobile', 'mobile' === layout[2] || (!layout && 1000 > innerWidth));
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,12 @@ abstract class Crypt
|
||||||
*/
|
*/
|
||||||
private static function Passphrase(?string $key) : string
|
private static function Passphrase(?string $key) : string
|
||||||
{
|
{
|
||||||
return \sha1(
|
if (!$key) {
|
||||||
($key ?: \preg_replace('/[^a-z]+/i', '', \explode(')', $_SERVER['HTTP_USER_AGENT'])[0])) . APP_SALT,
|
$key = isset($_COOKIE['smctoken'])
|
||||||
true
|
? $_COOKIE['smctoken']
|
||||||
);
|
: \preg_replace('/[^a-z]+/i', '', \explode(')', $_SERVER['HTTP_USER_AGENT'])[0]);
|
||||||
|
}
|
||||||
|
return \sha1($key . APP_SALT, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function Decrypt(array $data, string $key = null) /* : mixed */
|
public static function Decrypt(array $data, string $key = null) /* : mixed */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue