More edits

This commit is contained in:
2025-10-15 15:54:20 +02:00
parent 7e7830f57d
commit 17cd091325
2 changed files with 12 additions and 4 deletions

View File

@@ -415,8 +415,13 @@ function bindSmapiSoapServiceToExpress(
const credentialsFrom = E.fromNullable(new MissingLoginTokenError());
return pipe(
credentialsFrom(credentials),
E.chain((credentials) =>
pipe(
E.chain((credentials) => {
// Check if token/key is associated with a user
const smapiToken = sonosSoap.getCredentialsForToken(credentials.loginToken.token);
if (!smapiToken || smapiToken.key !== credentials.loginToken.key) {
return E.left(new InvalidTokenError("Token not associated with any user"));
}
return pipe(
smapiAuthTokens.verify({
token: credentials.loginToken.token,
key: credentials.loginToken.key,
@@ -425,8 +430,8 @@ function bindSmapiSoapServiceToExpress(
serviceToken,
credentials,
}))
)
),
);
}),
E.map(({ serviceToken, credentials }) => ({
serviceToken,
credentials,