export async function signIn()

in src/Frontend/src/services/auth.ts [11:42]


export async function signIn(email: string, password: string) : Promise<IAuthSigninResponse | null> {
    return new Promise<IAuthSigninResponse | null>((resolve, reject) => {
        try {
            const bodyData = {
                email_address: email,
                password
            }

            api.post(ENDPOINT_AUTH_TOKEN, bodyData).then(response => {        
                const { id, access_token, refresh_token, token_type, scopes, user_name, user_id } = response.data;
                resolve({ 
                    id,
                    access_token, 
                    refresh_token,
                    token_type,
                    scopes,
                    email,
                    user_name,
                    user_id
                });
            }).catch(e => {
                AlertInstance.alert(ALERT_ERROR, 'toast.errors.auth.error_auth');
                if (process.env.NODE_ENV === 'development') console.error('[REQUEST ERROR]: ' + e);
                reject(null);
            });
        } catch (e) {
            AlertInstance.alert(ALERT_ERROR, 'toast.errors.auth.error_auth');
            if (process.env.NODE_ENV === 'development') console.error('[PROMISE ERROR]: ' + e);
            reject(null);
        }
    });            
}