Fireship · @fireship

Anonymous Authentication with Angular and Firebase - Lazy Registration

Uploaded April 19, 2017 · Length 2:40

Anonymous Authentication with Angular and Firebase - Lazy Registration

Summary

build anonymous auth with angular and firebase for lazy registration

  • angular anonymous auth
  • firebase lazy registration
  • angularfire package
  • anonymous authentication

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    in this episode we're going to build an

  2. 0:02

    anonymous authorization service with

  3. 0:04

    angular 4 and fire-based this feature

  4. 0:07

    will allow user to start using your app

  5. 0:09

    without going through the typical ooofff

  6. 0:11

    sign end or email password registration

  7. 0:14

    process this approach is also called

  8. 0:16

    lazy registration or gradual engagement

  9. 0:20

    it works by creating a session using

  10. 0:22

    only the user ID if the user signs out

  11. 0:26

    without updating more account details

  12. 0:27

    they will be unable to log back in and

  13. 0:30

    retrieve any data that they created at

  14. 0:33

    this point it's assumed that you have

  15. 0:34

    the angularfire to package installed and

  16. 0:36

    bootstrapped in your application if not

  17. 0:39

    good at the docs or check out this video

  18. 0:41

    if starting from scratch generate the

  19. 0:45

    office service I'm actually going to be

  20. 0:47

    building upon the all service from my

  21. 0:49

    previous the last tutorial so I

  22. 0:51

    recommend checking out that video first

  23. 0:53

    if you haven't already head over to your

  24. 0:55

    firebase project and enable the

  25. 0:58

    anonymous provider first make sure to

  26. 1:04

    subscribe to the firebase off state in

  27. 1:06

    the constructor then write a function to

  28. 1:09

    login the user with the anonymous

  29. 1:11

    provider and let's also add a typescript

  30. 1:14

    getter to see if a user who's currently

  31. 1:17

    logged in is anonymous or not this will

  32. 1:20

    be useful when displaying content

  33. 1:21

    specifically for anonymous users in the

  34. 1:24

    template

  35. 1:27

    now we can inject the service into our

  36. 1:30

    components to login users and

  37. 1:31

    automatically in this case we just bind

  38. 1:34

    the function to the click event of any

  39. 1:36

    button or length in the template when

  40. 1:41

    the anonymous user decides to upgrade

  41. 1:43

    you'll need to transfer the account data

  42. 1:45

    to a new account or somehow link the two

  43. 1:48

    accounts together the firebase Web API

  44. 1:51

    supports account linking but in order to

  45. 1:54

    do this you would need to bypass the

  46. 1:56

    angularfire to package is an alternative

  47. 1:59

    you can simply create a new account and