(user)
| 229 | |
| 230 | // Triggers when the auth state change for instance when the user signs-in or signs-out. |
| 231 | function authStateObserver(user) { |
| 232 | if (user) { // User is signed in! |
| 233 | // Get the signed-in user's profile pic and name. |
| 234 | var profilePicUrl = getProfilePicUrl(); |
| 235 | var userName = getUserName(); |
| 236 | |
| 237 | // Set the user's profile pic and name. |
| 238 | userPicElement.style.backgroundImage = 'url(' + addSizeToGoogleProfilePic(profilePicUrl) + ')'; |
| 239 | userNameElement.textContent = userName; |
| 240 | |
| 241 | // Show user's profile and sign-out button. |
| 242 | userNameElement.removeAttribute('hidden'); |
| 243 | userPicElement.removeAttribute('hidden'); |
| 244 | signOutButtonElement.removeAttribute('hidden'); |
| 245 | |
| 246 | // Hide sign-in button. |
| 247 | signInButtonElement.setAttribute('hidden', 'true'); |
| 248 | |
| 249 | // We save the Firebase Messaging Device token and enable notifications. |
| 250 | saveMessagingDeviceToken(); |
| 251 | } else { // User is signed out! |
| 252 | // Hide user's profile and sign-out button. |
| 253 | userNameElement.setAttribute('hidden', 'true'); |
| 254 | userPicElement.setAttribute('hidden', 'true'); |
| 255 | signOutButtonElement.setAttribute('hidden', 'true'); |
| 256 | |
| 257 | // Show sign-in button. |
| 258 | signInButtonElement.removeAttribute('hidden'); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | // Returns true if user is signed-in. Otherwise false and displays a message. |
| 263 | function checkSignedInWithMessage() { |
nothing calls this directly
no test coverage detected