User configurable locale (language) (#10204)

* Support for system APP_LOCALE

* Start preferences re-write

* port 2fa form

* Working user preferences

* Language user preference

* Don't look up locale from the DB every request

* Device list working

* Deny demo user middleware

* Finish password changing

* remove used resource methods

* remove leftover use

* warn that translation is incomplete

* fix style
This commit is contained in:
Tony Murray
2019-05-23 10:05:45 -05:00
committed by GitHub
parent 90bb68f026
commit 90a67c2ece
15 changed files with 449 additions and 250 deletions

View File

@@ -55,7 +55,7 @@ class TwoFactor
/**
* Base32 Decoding dictionary
*/
private static $base32 = array(
private static $base32 = [
"A" => 0,
"B" => 1,
"C" => 2,
@@ -88,7 +88,7 @@ class TwoFactor
"5" => 29,
"6" => 30,
"7" => 31
);
];
/**
* Base32 Encoding dictionary
@@ -195,4 +195,20 @@ class TwoFactor
(ord($hash[$offset + 3]) & 0xff)) % pow(10, self::OTP_SIZE);
return str_pad($truncated, self::OTP_SIZE, '0', STR_PAD_LEFT);
}
/**
* Generate 2fa URI
* @param string $username
* @param string $key
* @param bool $counter if type is counter (false for time based)
* @return string
*/
public static function generateUri($username, $key, $counter = false)
{
$title = "LibreNMS:" . urlencode($username);
return $counter ?
"otpauth://hotp/$title?issuer=LibreNMS&counter=1&secret=$key" : // counter based
"otpauth://totp/$title?issuer=LibreNMS&secret=$key"; // time based
}
}