updates
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* Login with Github Function
|
||||
* ===============================================================================
|
||||
* @description This function uses google identity api to login a user with datasquirel
|
||||
*
|
||||
* @async
|
||||
*
|
||||
* @param {object} params - Single object passed
|
||||
* @param {string} params.clientId - Github app client ID: {@link https://datasquirel.com/docs}
|
||||
* @param {string} params.redirectUrl - Github Redirect URL as listed in your oauth app settings: {@link https://datasquirel.com/docs}
|
||||
* @param {function(boolean): void} [params.setLoading] - React setState Function: sets whether the google login button is ready or not
|
||||
*
|
||||
* @returns {void} - Return
|
||||
*/
|
||||
module.exports = function getAccessToken({ clientId, redirectUrl, setLoading }) {
|
||||
/**
|
||||
* == Initialize
|
||||
*
|
||||
* @description Initialize
|
||||
*/
|
||||
if (setLoading) setLoading(true);
|
||||
|
||||
const fetchUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=user&redirect_uri=${redirectUrl}${window.location.pathname}`;
|
||||
window.location.assign(fetchUrl);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
@@ -1,3 +1,5 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* Imports
|
||||
*/
|
||||
@@ -5,6 +7,7 @@ const imageInputFileToBase64 = require("./media/imageInputFileToBase64");
|
||||
const imageInputToBase64 = require("./media/imageInputToBase64");
|
||||
const inputFileToBase64 = require("./media/inputFileToBase64");
|
||||
const getAccessToken = require("./auth/google/getAccessToken");
|
||||
const getGithubAccessToken = require("./auth/github/getAccessToken");
|
||||
const logout = require("./auth/logout");
|
||||
|
||||
////////////////////////////////////////
|
||||
@@ -27,6 +30,9 @@ const auth = {
|
||||
google: {
|
||||
getAccessToken: getAccessToken,
|
||||
},
|
||||
github: {
|
||||
getAccessToken: getGithubAccessToken,
|
||||
},
|
||||
logout: logout,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user