feat(discord): add auth

This commit is contained in:
Ali BARIN
2022-10-29 16:43:44 +02:00
parent c46fbef03c
commit 2f9e40fc0e
13 changed files with 365 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import { TBeforeRequest } from '@automatisch/types';
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
const { tokenType, accessToken } = $.auth.data;
if (tokenType && accessToken) {
requestConfig.headers.Authorization = `${tokenType} ${accessToken}`;
}
return requestConfig;
};
export default addAuthHeader;

View File

@@ -0,0 +1,10 @@
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
const response = await $.http.get('/users/@me');
const currentUser = response.data;
return currentUser;
};
export default getCurrentUser;

View File

@@ -0,0 +1,3 @@
const scopes = ['identify', 'email'];
export default scopes;