Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
document.addEventListener('DOMContentLoaded', () => {
// Init sign-in library.
hello.init({
github: process.env.GITHUB_CLIENT_PUBLIC_ID,
}, {
redirect_uri: '/redirect.html',
});
const loggerMiddleware = createLogger();
const store = createStore(
connectRouter(history)(rootReducer),
{},
compose(
applyMiddleware(
routerMiddleware(history),
thunkMiddleware,
loggerMiddleware,
),
initHello () {
const credentials = {
facebook: process.env.HELLO_FACEBOOK,
google: process.env.HELLO_GOOGLE,
github: process.env.HELLO_GITHUB
}
const options = {
scope: 'email',
redirect_uri: process.env.HELLO_REDIRECT_URI
}
hello.init(credentials, options)
this.hello = hello.bind(hello)
}
}
import hello from 'hellojs';
const credentials = {};
const options = {};
credentials.facebook = APP_CONFIG.FACEBOOK_ID;
credentials.google = APP_CONFIG.GOOGLE_ID;
credentials.github = APP_CONFIG.GITHUB_ID;
options.redirect_uri = `${location.protocol}//${location.host}`;
options.scope = 'email';
hello.init(credentials, options);
export default hello;
export const signInWithGithub = () => new Promise((resolve) => {
hellojs.init({
github: GITHUB_CLIENT_ID,
}, {
oauth_proxy: `${API_URL}/oauthproxy`,
});
hellojs
.login('github')
.then(auth => {
hellojs(auth.network).api('/me').then(user => {
resolve({
user: {
access_token: auth.authResponse.access_token,
...user,
},
});
});
initOAuth() {
hello.init({google: config.auth.google.clientID}, {redirect_uri: '/'});
this.checkUser();
},
componentDidMount() {
const {
tenantName,
policyName,
redirectUrl,
backendClientApiID,
backendClientScopeName,
backendClientID
} = config;
hello.init({
azureAD: {
name: 'Azure Active Directory B2C',
oauth: {
version: 2,
auth: getAuthUrl(tenantName, policyName),
grant: getGrantUrl(tenantName, policyName)
},
refresh: true,
scope_delim: ' ',
logout: function () {
window.location = getLogoutUrl(tenantName, policyName, redirectUrl);
return true
},
form: false
}
});
import {createConstants, createReducer} from 'redux-module-builder'
import {createApiHandler, createApiAction} from 'redux-module-builder/api'
import hello from 'hellojs'
hello.init({
twitter: __TWITTER_KEY__
}, {
oauth_proxy: `${__API_URL__}/oauthproxy`
});
/*
* Constants
*
* Basic constants can just be a name
* i.e. 'GET_ME'
* and api constants can be an Object
* i.e. { 'GET_UPCOMING': { api: true }}
*/
export const types = createConstants('users')(
'LOGIN',
'LOGGED_IN',
async oauthLogin (ev) {
ev.preventDefault();
const id = ev.target.getAttribute('data-id');
this.provider = _converse.oauth_providers.get(id);
this.oauth_service = hello(id);
const data = {};
data[id] = this.provider.get('client_id');
hello.init(data, {
'redirect_uri': '/redirect.html'
});
await this.oauth_service.login();
this.fetchOAuthProfileDataAndLogin();
}
});