Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await this.mergeService.mergeDeck(mergeInfo.deckId, mergeInfo.userToken, user.id);
// Delete previous anonymous user from our backend
await this.userService.delete(mergeInfo.userId, mergeInfo.userToken);
// Delete previous anonymous user from Firebase
if (this.firebaseUser) {
await this.firebaseUser.delete();
}
await this.navigateRedirect();
resolve();
});
await firebase.auth().signInWithCredential(cred);
resolve();
});
};
loadDocument() {
if (this.startedLoad) { return null; }
this.startedLoad = true;
/* Authenticate with Firebase if a firebaseToken is provided in the client data */
const authenticationFunction = this.localClientData.firebaseToken
? firebase.auth(this.firebaseApp).signInWithCustomToken(this.localClientData.firebaseToken)
: new Promise((resolve)=> { return resolve(); });
return authenticationFunction
.then(()=> {
/* Load the checkpoint if available */
return this.firebaseRef.child('checkpoint').once('value');
})
.then((checkpointSnapshot) => {
const checkpointSnapshotVal = checkpointSnapshot.val() || { k: '0', d: { type: 'doc', attrs: { meta: {} }, content: [{ type: 'paragraph' }] } };
this.mostRecentRemoteKey = Number(checkpointSnapshotVal.k);
const newDoc = Node.fromJSON(this.view.state.schema, uncompressStateJSON({ d: checkpointSnapshotVal.d }).doc);
/* Get all changes since mostRecentRemoteKey */
const getChanges = this.firebaseRef.child('changes')
.orderByKey()
'firebase-ui-css',
'https://cdn.firebase.com/libs/firebaseui/4.0.0/firebaseui.css'
);
const appUrl: string = EnvironmentConfigService.getInstance().get('appUrl');
const redirectUrl: string = await get('deckdeckgo_redirect');
const mergeInfo: MergeInformation = await get('deckdeckgo_redirect_info');
const signInOptions = [];
signInOptions.push(firebase.auth.GoogleAuthProvider.PROVIDER_ID);
signInOptions.push(firebase.auth.GithubAuthProvider.PROVIDER_ID);
signInOptions.push(firebase.auth.EmailAuthProvider.PROVIDER_ID);
this.firebaseUser = firebase.auth().currentUser;
const uiConfig = {
signInFlow: 'redirect',
signInSuccessUrl: appUrl,
signInOptions: signInOptions,
// tosUrl and privacyPolicyUrl accept either url string or a callback
// function.
// Terms of service url/callback.
tosUrl: appUrl + '/terms',
// Privacy policy url/callback.
privacyPolicyUrl: appUrl + '/privacy',
credentialHelper: firebaseui.auth.CredentialHelper.GOOGLE_YOLO,
autoUpgradeAnonymousUsers: true,
callbacks: {
signInSuccessWithAuthResult: (_authResult, _redirectUrl) => {
this.signInInProgress = true;
// Ultimately I would like to transfer here the userService.updateMergedUser if async would be supported
this.navigateRoot(redirectUrl, mergeInfo);
return false;
},
// signInFailure callback must be provided to handle merge conflicts which
// occur when an existing credential is linked to an anonymous user.
signInFailure: this.onSignInFailure
}
};
window['firebase'] = firebase;
await this.saveRedirect();
const ui = firebaseui.auth.AuthUI.getInstance() || new firebaseui.auth.AuthUI(firebase.auth());
if (!ui.isPendingRedirect()) {
ui.reset();
}
// The start method will wait until the DOM is loaded.
ui.start('#firebaseui-auth-container', uiConfig);
}
function signinWithToken (token = '') {
return firebase.auth().signInWithCustomToken(token)
.then((res) => {
return updateCurrentUser(res.user);
});
}
let config = {
apiKey: firebaseKey,
authDomain: "myrjsecg.firebaseapp.com",
databaseURL: "https://myrjsecg.firebaseio.com",
projectId: "myrjsecg",
storageBucket: "gs://myrjsecg.appspot.com",
messagingSenderId: "967963389163"
};
firebase.initializeApp(config);
export default firebase;
export const provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({
prompt: "select_account"
});
export const auth = firebase.auth();
export const db = firebase.firestore();
export const scenes = db.collection("scenes");
export const snaps = db.collection("snaps");
export const classes = db.collection("classes");
export const storageRef = firebase.storage().ref();
getChildContext() {
const { app, select, selectAuth, selectStorage, store } = this.props.store;
return {
firebase: {
app,
auth: firebase.auth(app),
firestore: firebase.firestore(app),
messaging: firebase.messaging(app),
select,
selectAuth,
selectStorage,
storage: firebase.storage(app),
store
}
};
}
var signin = (params = {}) => {
return firebase.auth().signInWithEmailAndPassword(params.email, params.password)
.then((authRes) => {
return updateCurrentUser(authRes.user);
}).catch((err) => {
return signinError(err);
});
};
getName = () => {
let user = firebase.auth().currentUser, name = 'Rando Calrissian';
if (user) {
if (user.email) name = user.email;
else if (user.phoneNumber) name = user.phoneNumber;
}
return name;
};