[PLUGIN][Pinboard] Change token to user user ID rather than nickname, to avoid complications with it possibly changing

This commit is contained in:
2022-03-31 22:06:37 +01:00
parent 94ab4ce8c4
commit 1664293cf7
4 changed files with 15 additions and 32 deletions

View File

@@ -25,7 +25,7 @@ class Settings extends Controller
public static function setup()
{
$user = Common::ensureLoggedIn();
$token = Token::get(nickname: null, token: null, user: $user);
$token = Token::get(id: null, token: null, user: $user);
$enabled = ($token?->getEnabled() ?? false);
$form = Form::create([
['token', TextType::class, ['label' => _m('The token used to authenticate you via the Pinboard-compatible API'), 'data' => $token?->getUserTokenString(), 'disabled' => true]],
@@ -79,7 +79,7 @@ class Settings extends Controller
} else {
throw new ClientException(_m('Invalid form submission'));
}
Cache::set(Token::cacheKeys($user->getNickname())['user-token'], $token);
Cache::set(Token::cacheKeys($user->getId())['user-token'], $token);
DB::flush();
return Form::forceRedirect($form, $request);
}