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