Skip to content

Commit 8b4491a

Browse files
committed
fix: Add translation for temporary app password names
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent f4acd8a commit 8b4491a

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

apps/settings/lib/Controller/AuthSettingsController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use OCP\Authentication\Exceptions\WipeTokenException;
2828
use OCP\Authentication\Token\IToken;
2929
use OCP\IConfig;
30+
use OCP\IL10N;
3031
use OCP\IRequest;
3132
use OCP\ISession;
3233
use OCP\IUserSession;
@@ -49,6 +50,7 @@ public function __construct(
4950
private RemoteWipe $remoteWipe,
5051
private LoggerInterface $logger,
5152
private IConfig $serverConfig,
53+
private IL10N $l,
5254
) {
5355
parent::__construct($appName, $request);
5456
}
@@ -92,11 +94,13 @@ public function create(string $name = '', bool $qrcodeLogin = false): JSONRespon
9294

9395
if ($qrcodeLogin) {
9496
if ($this->appConfig->getAppValueBool(ConfigLexicon::LOGIN_QRCODE_ONETIME)) {
95-
$name = 'One time login';
97+
// TRANSLATORS Fallback name for the temporary app password when using the QR code login
98+
$name = $this->l->t('One time login');
9699
$type = IToken::ONETIME_TOKEN;
97100
$scope = [];
98101
} else {
99-
$name = 'QR Code login';
102+
// TRANSLATORS Fallback name for the app password when using the QR code login
103+
$name = $this->l->t('QR Code login');
100104
$type = IToken::PERMANENT_TOKEN;
101105
$scope = null;
102106
}

apps/settings/tests/Controller/AuthSettingsControllerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use OCP\AppFramework\Http\JSONResponse;
2222
use OCP\AppFramework\Services\IAppConfig;
2323
use OCP\IConfig;
24+
use OCP\IL10N;
2425
use OCP\IRequest;
2526
use OCP\ISession;
2627
use OCP\IUserSession;
@@ -40,6 +41,7 @@ class AuthSettingsControllerTest extends TestCase {
4041
private IAppConfig&MockObject $appConfig;
4142
private RemoteWipe&MockObject $remoteWipe;
4243
private IConfig&MockObject $serverConfig;
44+
private IL10N&MockObject $l;
4345
private string $uid = 'jane';
4446
private AuthSettingsController $controller;
4547

@@ -57,6 +59,7 @@ protected function setUp(): void {
5759
$this->serverConfig = $this->createMock(IConfig::class);
5860
/** @var LoggerInterface&MockObject $logger */
5961
$logger = $this->createMock(LoggerInterface::class);
62+
$this->l = $this->createMock(IL10N::class);
6063

6164
$this->controller = new AuthSettingsController(
6265
'core',
@@ -71,6 +74,7 @@ protected function setUp(): void {
7174
$this->remoteWipe,
7275
$logger,
7376
$this->serverConfig,
77+
$this->l,
7478
);
7579
}
7680

build/psalm-baseline.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4237,12 +4237,6 @@
42374237
<ImplementedReturnTypeMismatch>
42384238
<code><![CDATA[boolean|null]]></code>
42394239
</ImplementedReturnTypeMismatch>
4240-
<LessSpecificReturnStatement>
4241-
<code><![CDATA[$this->tokenProvider->getToken($password)]]></code>
4242-
</LessSpecificReturnStatement>
4243-
<MoreSpecificReturnType>
4244-
<code><![CDATA[?IToken]]></code>
4245-
</MoreSpecificReturnType>
42464240
<NoInterfaceProperties>
42474241
<code><![CDATA[$request->server]]></code>
42484242
<code><![CDATA[$request->server]]></code>

lib/private/User/Session.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,9 @@ protected function isTwoFactorEnforced($username) {
493493
/**
494494
* Check if the given 'password' is actually a device token
495495
*
496-
* @param string $password
497-
* @return ?IToken
498496
* @throws ExpiredTokenException
499497
*/
500-
private function getTokenFromPassword(string $password): ?IToken {
498+
private function getTokenFromPassword(string $password): ?\OCP\Authentication\Token\IToken {
501499
try {
502500
return $this->tokenProvider->getToken($password);
503501
} catch (ExpiredTokenException $e) {

0 commit comments

Comments
 (0)