Merge pull request #697 from automatisch/refactor-is-still-verified
refactor: abstract exception capture out of is-still-verified
This commit is contained in:
@@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types';
|
|||||||
import verifyCredentials from './verify-credentials';
|
import verifyCredentials from './verify-credentials';
|
||||||
|
|
||||||
const isStillVerified = async ($: IGlobalVariable) => {
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
try {
|
|
||||||
await verifyCredentials($);
|
await verifyCredentials($);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default isStillVerified;
|
export default isStillVerified;
|
||||||
|
@@ -2,13 +2,9 @@ import { IGlobalVariable } from '@automatisch/types';
|
|||||||
import getCurrentUser from '../common/get-current-user';
|
import getCurrentUser from '../common/get-current-user';
|
||||||
|
|
||||||
const isStillVerified = async ($: IGlobalVariable) => {
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
try {
|
|
||||||
await getCurrentUser($);
|
await getCurrentUser($);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default isStillVerified;
|
export default isStillVerified;
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import { IGlobalVariable } from '@automatisch/types';
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
|
||||||
const isStillVerified = async ($: IGlobalVariable) => {
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
try {
|
|
||||||
const params = {
|
const params = {
|
||||||
method: 'flickr.test.login',
|
method: 'flickr.test.login',
|
||||||
format: 'json',
|
format: 'json',
|
||||||
@@ -9,9 +8,6 @@ const isStillVerified = async ($: IGlobalVariable) => {
|
|||||||
};
|
};
|
||||||
const response = await $.http.get('/rest', { params });
|
const response = await $.http.get('/rest', { params });
|
||||||
return !!response.data.user.id;
|
return !!response.data.user.id;
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default isStillVerified;
|
export default isStillVerified;
|
||||||
|
@@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types';
|
|||||||
import getCurrentUser from '../common/get-current-user';
|
import getCurrentUser from '../common/get-current-user';
|
||||||
|
|
||||||
const isStillVerified = async ($: IGlobalVariable) => {
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
try {
|
|
||||||
const user = await getCurrentUser($);
|
const user = await getCurrentUser($);
|
||||||
return !!user.id;
|
return !!user.id;
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default isStillVerified;
|
export default isStillVerified;
|
||||||
|
@@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types';
|
|||||||
import getCurrentUser from '../common/get-current-user';
|
import getCurrentUser from '../common/get-current-user';
|
||||||
|
|
||||||
const isStillVerified = async ($: IGlobalVariable) => {
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
try {
|
|
||||||
const user = await getCurrentUser($);
|
const user = await getCurrentUser($);
|
||||||
return !!user;
|
return !!user;
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default isStillVerified;
|
export default isStillVerified;
|
||||||
|
@@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types';
|
|||||||
import getCurrentUser from '../common/get-current-user';
|
import getCurrentUser from '../common/get-current-user';
|
||||||
|
|
||||||
const isStillVerified = async ($: IGlobalVariable) => {
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
try {
|
|
||||||
const user = await getCurrentUser($);
|
const user = await getCurrentUser($);
|
||||||
return !!user.id;
|
return !!user.id;
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default isStillVerified;
|
export default isStillVerified;
|
||||||
|
@@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types';
|
|||||||
import verifyCredentials from './verify-credentials';
|
import verifyCredentials from './verify-credentials';
|
||||||
|
|
||||||
const isStillVerified = async ($: IGlobalVariable) => {
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
try {
|
|
||||||
await verifyCredentials($);
|
await verifyCredentials($);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default isStillVerified;
|
export default isStillVerified;
|
||||||
|
@@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types';
|
|||||||
import verifyCredentials from './verify-credentials';
|
import verifyCredentials from './verify-credentials';
|
||||||
|
|
||||||
const isStillVerified = async ($: IGlobalVariable) => {
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
try {
|
|
||||||
await verifyCredentials($);
|
await verifyCredentials($);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default isStillVerified;
|
export default isStillVerified;
|
||||||
|
@@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types';
|
|||||||
import getCurrentUser from '../common/get-current-user';
|
import getCurrentUser from '../common/get-current-user';
|
||||||
|
|
||||||
const isStillVerified = async ($: IGlobalVariable) => {
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
try {
|
|
||||||
const user = await getCurrentUser($);
|
const user = await getCurrentUser($);
|
||||||
return !!user;
|
return !!user;
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default isStillVerified;
|
export default isStillVerified;
|
||||||
|
@@ -22,7 +22,12 @@ const testConnection = async (
|
|||||||
const app = await App.findOneByKey(connection.key, false);
|
const app = await App.findOneByKey(connection.key, false);
|
||||||
const $ = await globalVariable({ connection, app });
|
const $ = await globalVariable({ connection, app });
|
||||||
|
|
||||||
const isStillVerified = await app.auth.isStillVerified($);
|
let isStillVerified;
|
||||||
|
try {
|
||||||
|
isStillVerified = !!(await app.auth.isStillVerified($));
|
||||||
|
} catch {
|
||||||
|
isStillVerified = false;
|
||||||
|
}
|
||||||
|
|
||||||
connection = await connection.$query().patchAndFetch({
|
connection = await connection.$query().patchAndFetch({
|
||||||
formattedData: connection.formattedData,
|
formattedData: connection.formattedData,
|
||||||
|
Reference in New Issue
Block a user