(user)
| 246 | |
| 247 | // Triggers when the auth state change for instance when the user signs-in or signs-out. |
| 248 | function authStateObserver(user) { |
| 249 | if (user) { // User is signed in! |
| 250 | // Get the signed-in user's profile pic and name. |
| 251 | var profilePicUrl = getProfilePicUrl(); |
| 252 | var userName = getUserName(); |
| 253 | |
| 254 | // Set the user's profile pic and name. |
| 255 | userPicElement.style.backgroundImage = 'url(' + addSizeToGoogleProfilePic(profilePicUrl) + ')'; |
| 256 | userNameElement.textContent = userName; |
| 257 | |
| 258 | // Show user's profile and sign-out button. |
| 259 | userNameElement.removeAttribute('hidden'); |
| 260 | userPicElement.removeAttribute('hidden'); |
| 261 | signOutButtonElement.removeAttribute('hidden'); |
| 262 | |
| 263 | // Hide sign-in button. |
| 264 | signInButtonElement.setAttribute('hidden', 'true'); |
| 265 | |
| 266 | // We save the Firebase Messaging Device token and enable notifications. |
| 267 | saveMessagingDeviceToken(); |
| 268 | } else { // User is signed out! |
| 269 | // Hide user's profile and sign-out button. |
| 270 | userNameElement.setAttribute('hidden', 'true'); |
| 271 | userPicElement.setAttribute('hidden', 'true'); |
| 272 | signOutButtonElement.setAttribute('hidden', 'true'); |
| 273 | |
| 274 | // Show sign-in button. |
| 275 | signInButtonElement.removeAttribute('hidden'); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | // Returns true if user is signed-in. Otherwise false and displays a message. |
| 280 | function checkSignedInWithMessage() { |
nothing calls this directly
no test coverage detected