Updates
This commit is contained in:
+16
-31
@@ -1,44 +1,29 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = getAccessToken;
|
||||
exports.googleLogin = googleLogin;
|
||||
let interval;
|
||||
/**
|
||||
* Login with Google Function
|
||||
* ===============================================================================
|
||||
* @description This function uses google identity api to login a user with datasquirel
|
||||
*/
|
||||
function getAccessToken(params) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a, _b;
|
||||
(_a = params.setLoading) === null || _a === void 0 ? void 0 : _a.call(params, true);
|
||||
const response = (yield new Promise((resolve, reject) => {
|
||||
interval = setInterval(() => {
|
||||
// @ts-ignore
|
||||
let google = window.google;
|
||||
if (google) {
|
||||
window.clearInterval(interval);
|
||||
resolve(googleLogin(Object.assign(Object.assign({}, params), { google })));
|
||||
}
|
||||
}, 500);
|
||||
}));
|
||||
(_b = params.setLoading) === null || _b === void 0 ? void 0 : _b.call(params, false);
|
||||
return response;
|
||||
});
|
||||
export default async function getAccessToken(params) {
|
||||
var _a, _b;
|
||||
(_a = params.setLoading) === null || _a === void 0 ? void 0 : _a.call(params, true);
|
||||
const response = (await new Promise((resolve, reject) => {
|
||||
interval = setInterval(() => {
|
||||
// @ts-ignore
|
||||
let google = window.google;
|
||||
if (google) {
|
||||
window.clearInterval(interval);
|
||||
resolve(googleLogin(Object.assign(Object.assign({}, params), { google })));
|
||||
}
|
||||
}, 500);
|
||||
}));
|
||||
(_b = params.setLoading) === null || _b === void 0 ? void 0 : _b.call(params, false);
|
||||
return response;
|
||||
}
|
||||
/**
|
||||
* # Google Login Function
|
||||
*/
|
||||
function googleLogin({ google, clientId, setLoading, triggerPrompt, }) {
|
||||
export function googleLogin({ google, clientId, setLoading, triggerPrompt, }) {
|
||||
setTimeout(() => {
|
||||
setLoading === null || setLoading === void 0 ? void 0 : setLoading(false);
|
||||
}, 3000);
|
||||
|
||||
Reference in New Issue
Block a user