mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-23 09:23:48 +01:00
handle authentication errors in stream API
This commit is contained in:
parent
ad2f017af8
commit
5217f18ca4
@ -17,10 +17,14 @@ export const initializeStreamingServer = (server: http.Server) => {
|
||||
ws.on('request', async (request) => {
|
||||
const q = request.resourceURL.query as ParsedUrlQuery;
|
||||
|
||||
// TODO: トークンが間違ってるなどしてauthenticateに失敗したら
|
||||
// コネクション切断するなりエラーメッセージ返すなりする
|
||||
// (現状はエラーがキャッチされておらずサーバーのログに流れて邪魔なので)
|
||||
const [user, app] = await authenticate(request.httpRequest.headers.authorization, q.i);
|
||||
const [user, app] = await authenticate(request.httpRequest.headers.authorization, q.i)
|
||||
.catch(err => {
|
||||
request.reject(403, err.message);
|
||||
return [];
|
||||
});
|
||||
if (typeof user === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user?.isSuspended) {
|
||||
request.reject(400);
|
||||
|
Loading…
Reference in New Issue
Block a user