Service functions - Garasje-folka/bartstua GitHub Wiki

User Management

changePassword

Parameters

  • currentPassword: The user's existing password
  • newPassword: The user's new password

Description

Changes the password of the currently signed in user. User has to be signed in to use this command.

createUserWithEmailAndPassword

Parameters

  • email: The new user's email
  • password: The new user's password

Description

Creates a user with the given email and password. Email should not be already registered. Password requirements: 6 character long

Errors

  • ERROR_EMAIL_ALREADY_USED: Email is already in use.
  • ERROR_EMAIL_NOT_VALID: Email is not formatted properly.
  • ERROR_WEAK_PASSWORD: Password is too weak.
  • ERROR_UNSUPPORTED_OPERATION: The operation is not supported by backend.
  • ERROR_UNKNOWN: Unknown error. Most likely something not working properly.

onCurrentUserChanged

Parameters

  • callback: A callback that takes a User or null as input

Description

Setting a callback that will run each time the current user's current authentication state changes. This will run on sign in, sign out, creating user etc. Using this function will replace the previous callback function. Avoid using it and use currentUserSelector from redux instead.

reauthenticate

Parameters

  • password: Password inputed by user

Description

Uses the current user's email to reauthenticate with the given password. This is primarily used to check if the user is inputing the correct password when the user is already signed in.

Errors

  • ERROR_WRONG_PASSWORD: The given password is wrong.
  • ERROR_UNKNOWN: Unknown error. Most likely something not working properly.

sendEmailVerification

Parameters

None

Description

Sends a email verification to the current user.

Errors

  • ERROR_UNKNOWN: Unknown error. Most likely something not working properly.

signInWithEmailAndPassword

Parameters

  • email: The user's email
  • password: The user's password

Description

Uses the given parameters to sign in. If everything went as expected, the currentUser state in redux should be updated.

Errors

  • ERROR_INVALID_EMAIL: Email is not formatted properly.
  • ERROR_USER_DISABLED: The user has been disabled.
  • ERROR_USER_NOT_FOUND: The user is not registered.
  • ERROR_WRONG_PASSWORD: The written password is wrong.
  • ERROR_UNKNOWN: Unknown error. Most likely something not working properly.

signOut

Parameters

None

Description

The currently signed in user (currentUser) will be signed out. The global state in redux will be updated accordingly.

signInAnonymously

Parameters

None

Description

Creates an anonymous account that gets signed in. This updates the currentUser redux state if it was successful. It does not create a new account if an anonymous user is already signed in.

Errors

  • ERROR_UNSUPPORTED_OPERATION: The operation is not supported by backend.
  • ERROR_UNKNOWN: Unknown error. Most likely something not working properly.