fix(placetel): Authenticate in case valid user without device
This commit is contained in:
@@ -1,11 +1,21 @@
|
|||||||
import { IGlobalVariable } from '@automatisch/types';
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
import HttpError from '../../../errors/http';
|
||||||
|
|
||||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||||
await $.http.post(`/1/messages.json`, {
|
try {
|
||||||
token: $.auth.data.apiToken as string,
|
await $.http.post(`/1/users/validate.json`, {
|
||||||
user: $.auth.data.userKey as string,
|
token: $.auth.data.apiToken as string,
|
||||||
message: 'hello world',
|
user: $.auth.data.userKey as string,
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
const noDeviceError = 'user is valid but has no active devices';
|
||||||
|
const hasNoDeviceError =
|
||||||
|
error.response?.data?.errors?.includes(noDeviceError);
|
||||||
|
|
||||||
|
if (!hasNoDeviceError) {
|
||||||
|
throw new HttpError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await $.auth.set({
|
await $.auth.set({
|
||||||
screenName: $.auth.data.screenName,
|
screenName: $.auth.data.screenName,
|
||||||
|
Reference in New Issue
Block a user