Revoke active casts
This commit is contained in:
parent
f39e095168
commit
18c3369fc0
2 changed files with 23 additions and 2 deletions
|
@ -37,7 +37,12 @@ export default function AlbumCastDialog(props: Props) {
|
|||
>('choose');
|
||||
|
||||
const [browserCanCast, setBrowserCanCast] = useState(false);
|
||||
|
||||
// Make API call on component mount
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
await castGateway.revokeAllTokens();
|
||||
})();
|
||||
}, []);
|
||||
const onSubmit: SingleInputFormProps['callback'] = async (
|
||||
value,
|
||||
setFieldError
|
||||
|
|
|
@ -20,6 +20,22 @@ class CastGateway {
|
|||
return resp.data.encCastData;
|
||||
}
|
||||
|
||||
public async revokeAllTokens() {
|
||||
try {
|
||||
const token = getToken();
|
||||
await HTTPService.delete(
|
||||
getEndpoint() + '/cast/revoke-all-tokens/',
|
||||
undefined,
|
||||
{
|
||||
'X-Auth-Token': token,
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
logError(e, 'removeAllTokens failed');
|
||||
// swallow error
|
||||
}
|
||||
}
|
||||
|
||||
public async getPublicKey(code: string): Promise<string> {
|
||||
let resp;
|
||||
try {
|
||||
|
@ -42,7 +58,7 @@ class CastGateway {
|
|||
}
|
||||
|
||||
public async registerDevice(code: string, publicKey: string) {
|
||||
await HTTPService.put(getEndpoint() + '/cast/device-info/', {
|
||||
await HTTPService.post(getEndpoint() + '/cast/device-info/', {
|
||||
deviceCode: `${code}`,
|
||||
publicKey: publicKey,
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue