How to use the firebase.auth function in firebase

To help you get started, we’ve selected a few firebase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hammer-io / yggdrasil / src / actions / session.js View on Github external
return async (dispatch) => {
    try {
      const fetchClient = new FetchClient()
      fetchClient.setAuthToken(token)
      // This endpoint doesn't return anything upon success (result is always null)
      // eslint-disable-next-line no-unused-vars
      const { result, error } = await fetchClient.delete({
        url: '/auth/logout'
      })
      if (!error) {
        dispatch(setAccessToken(null))
        dispatch(setUser(null))
        await firebase.auth().signOut()
        return
      }

      console.error(error)
      return { result: null, error }
    } catch (error) {
      logError(dispatch, error)
      return error
    }
  }
}
github jeroenouw / AngularMaterialFirebase / src / app / shared / services / user.service.ts View on Github external
verificationUserEmail() {
    firebase.auth().currentUser.sendEmailVerification().then(() => {
      // Email sent.
    }, (error) => {
      // An error happened.
    });
  }
github aofdev / vue-firebase-auth-vuex / src / store / user / index.js View on Github external
signUserInTwitter ({commit}) {
      commit('setLoading', true)
      commit('clearError')
      firebase.auth().signInWithPopup(new firebase.auth.TwitterAuthProvider())
        .then(
          user => {
            commit('setLoading', false)
            const newUser = {
              id: user.uid,
              name: user.displayName,
              email: user.email,
              photoUrl: user.photoURL
            }
            commit('setUser', newUser)
          }
        )
        .catch(
          error => {
            commit('setLoading', false)
            commit('setError', error)
github jeroenouw / AngularMaterialFirebase / src / app / components / profile / profile.component.ts View on Github external
state('small', style({
        transform: 'scale(1)',
      })),
      state('large', style({
        transform: 'scale(2)',
      })),

      transition('small <=> large', animate('500ms ease-in', keyframes([
        style({opacity: 0, transform: 'translateY(-80%)', offset: 0}),
        style({opacity: 1, transform: 'translateY(25px)', offset: 1})
      ]))),
    ]),
  ]
})
export class ProfileComponent implements OnInit {
  public uid = firebase.auth().currentUser.uid;

  public fullImagePath: string = '/assets/img/mb-bg-04.png';
  public profileTitle: string = 'My profile';
  public displayName: string = 'Your username';
  public bio: any = 'Your bio';
  public state: string = 'small';

  constructor(
    private userService: UserService,
    private alertService: AlertService) {}

  public ngOnInit(): Promise {
    return firebase.database().ref().child('users/' + this.uid).once('value').then((snap) => {
      this.displayName  = snap.val().displayName,
      this.bio = snap.val().bio
    });
github carlosazaustre / react-firebase-t3chfest / src / App.js View on Github external
handleLogout () {
    firebase.auth().signOut()
      .then(result => console.log(`${result.user.email} ha iniciado sesión`))
      .catch(error => console.log(`Error ${error.code}: ${error.message}`));
  }
github machinelabs / machinelabs / client / src / app / auth / auth.service.spec.ts View on Github external
authService.signOut().subscribe(() => {
          expect(firebase.auth().signOut).toHaveBeenCalled();
          done();
        });
      });
github open-apparel-registry / open-apparel-registry / src / app / src / actions / user.js View on Github external
export const logIn = (email, password) => () =>
    firebase.auth().signInWithEmailAndPassword(email, password);
export const logOut = () => () => firebase.auth().signOut();
github cerebral / cerebral / packages / firebase / src / getUser.js View on Github external
(result) => {
        if (result.user) {
          const user = createUser(result.user)

          if (result.credential) {
            user.accessToken = result.credential.accessToken
          }
          resolve({
            user: firebase.auth().currentUser ? user : null,
            isRedirected: true
          })
        } else {
          const unsubscribe = firebase.auth().onAuthStateChanged(user => {
            unsubscribe()
            resolve({
              user: user ? createUser(user) : null,
              isRedirected: false
            })
          })
        }
      }, (error) => {
        reject(new FirebaseProviderError(error))
github bulicmatko / firepack / src / containers / RootContainer / RootContainer.prod / Component / index.js View on Github external
componentWillMount() {
    const { router, dispatch } = this.props;
    const { firebaseConfig } = this.context;

    dispatch({ type: APP.SETUP });

    firebase.initializeApp(firebaseConfig);

    firebase
      .auth()
      .onAuthStateChanged(user => {
        if (user) {
          dispatch({
            type: AUTH.AUTHENTICATED,
            payload: {
              uid: user.uid,
              email: user.email,
              photoURL: user.photoURL,
              displayName: user.displayName,
              isAnonymous: user.isAnonymous,
              emailVerified: user.emailVerified,
            },
          });

          if (location.pathname.startsWith(route('auth'))) {
github hfogelberg / fb-auth-demo / src / components / AuthSuccess.vue View on Github external
created() {
     var vm = this
     firebase.auth().onAuthStateChanged(function(user) {
       if (user) {
         vm.user = user;
         vm.name = vm.user.displayName;
         vm.email = vm.user.email;
         vm.photo = vm.user.photoURL;
         vm.userId = vm.user.uid;
      }
    });
  },
  methods: {