Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(async (resolve) => {
try {
const loading: HTMLIonLoadingElement = await loadingController.create({});
await loading.present();
const firebaseUser: firebase.User = firebase.auth().currentUser;
if (firebaseUser) {
// We need the user token to access the API, therefore delete it here first
await this.apiUserService.delete(this.apiUser.id, this.authUser.token);
// Then delete the user
await this.userService.delete(this.authUser.uid);
// Decks and slides are delete with a cloud function triggered on auth.delete
await firebaseUser.delete();
}
return new Promise(async (resolve) => {
if (!this.deck || !this.deck.id || this.deck.id === undefined || this.deck.id === '') {
resolve();
return;
}
const loading: HTMLIonLoadingElement = await loadingController.create({});
await loading.present();
await this.deckService.delete(this.deck.id);
this.deckDeleted.emit(this.deck.id);
await loading.dismiss();
resolve();
});
}
handler: async (): Promise => {
const imageBlob = b64toBlob(image.url.replace("data:image/png;base64,", ""), 'image/jpg');
let provider = (window as any).mgt.Providers.globalProvider;
if (provider) {
let graphClient = provider.graph.client;
console.log(graphClient);
const loading = await loadingController.create({
message: "Uploading...",
showBackdrop: navigator.userAgent.includes('iPad') === false && window.matchMedia("(min-width: 1200px)").matches ? false : true
});
await loading.present();
await sheet.dismiss();
try {
const driveItem = await graphClient.api('/me/drive/root/children').middlewareOptions((window as any).mgt.prepScopes('user.read', 'files.readwrite')).post({
"name": "webboard",
"folder": {}
});
console.log(driveItem);
const fileUpload = await graphClient.api(`/me/drive/items/${driveItem.id}:/${image.name}.jpg:/content`).middlewareOptions((window as any).mgt.prepScopes('user.read', 'files.readwrite')).put(imageBlob);
console.log(fileUpload);
async refreshImages() {
const loading = await loadingController.create({
message: "Loading images from the cloud...",
showBackdrop: navigator.userAgent.includes('iPad') === false && window.matchMedia("(min-width: 1200px)").matches ? false : true
});
await loading.present();
console.log('trying to get images from the cloud');
try {
const data = await getSavedImages();
console.log(data);
this.images = data.images
await loading.dismiss();
await set('images', this.images);
}
async grabColor() {
const loading = await loadingCtrl.create({
message: "Analyzing...",
showBackdrop: navigator.userAgent.includes('iPad') === false && window.matchMedia("(min-width: 1200px)").matches ? false : true
});
await loading.present();
const blobPhoto = await this.capture.takePhoto();
let reader = new FileReader();
reader.readAsArrayBuffer(blobPhoto);
reader.onloadend = async () => {
const aiToken = localStorage.getItem('ai');
if (aiToken) {
const response = await fetch(`https://westus2.api.cognitive.microsoft.com/vision/v2.0/analyze?visualFeatures=Color`, {
headers: {
"Ocp-Apim-Subscription-Key": "d930861b5bba49e5939b843f9c4e5846",
"Content-Type": "application/octet-stream"