registerLogInLogOut()
Controller for that handles user registration (new user), user login, and user logout. Makes use of databaseAndAuth and runListeners factories.
- Source:
Methods
(static) '$scope.logIn'()
Handles user login. Logs in an existing user (using Firebase native method 'signInWithEmailAndPassword'). Uses promises to register successful login or to catch erors. Upon login, removes any text from the input fields. Upon erorr, shows the error message to the user
(static) '$scope.logOut'()
Handles user logout. Logs out an existing user (using Firebase native methods 'remove()' and 'signOut()'). Uses promises. When user clicks the logout button, removes their coordinates from the database. After that it broadcasts (on $rootScope) that the user has logged out, and then it signs them out to remove any session data. Note: Database stores their chat messages and location, while authentication holds their session. That's why both need to be removed using .remove() and .signOut()
(static) '$scope.register'()
Handles uer registration. Creates a new user (uding Firebase native method 'createUserWithEmailAndPassword'). Extracts username from user's email (username is anything that comes before @ symbol e.g. john06@gmail.com will have username of john06). Uses promises to add user to the database after they are created. Each user is listed under their unique Id provided by Firebase authentication system (user.uid)
- Source: