Class: Firebase::Authentication::Service
- Inherits:
-
Object
- Object
- Firebase::Authentication::Service
- Defined in:
- lib/firebase/authentication/service.rb
Overview
A Ruby wrapper for Firebase REST API
Query the Firebase Auth backend through a REST API
Instance Method Summary collapse
-
#change_email(token, email) ⇒ Net::HTTPOK
Change a user’s email.
-
#change_password(token, password) ⇒ Net::HTTPOK
Change a user’s password.
-
#delete_account(token) ⇒ Net::HTTPOK
Delete a user.
-
#exchange_custom_token(token) ⇒ Net::HTTPOK
Exchange a custom Auth token for an ID and refresh token.
-
#get_account_info(token) ⇒ Net::HTTPOK
Get a user’s data.
-
#initialize(api_key, logger = Rails.logger) ⇒ Service
constructor
A new instance of Service.
-
#send_password_reset_email(email) ⇒ Net::HTTPOK
Send a password reset email.
-
#sign_in_email(email, password) ⇒ Net::HTTPOK
Signin a user.
-
#sign_up(email, password) ⇒ Net::HTTPOK
Signup new user.
Constructor Details
#initialize(api_key, logger = Rails.logger) ⇒ Service
Returns a new instance of Service.
21 22 23 24 |
# File 'lib/firebase/authentication/service.rb', line 21 def initialize(api_key, logger = Rails.logger) @logger = logger @api_key = api_key end |
Instance Method Details
#change_email(token, email) ⇒ Net::HTTPOK
Change a user’s email.
39 40 41 42 43 |
# File 'lib/firebase/authentication/service.rb', line 39 def change_email(token, email) res = fetch(:post, Config::UPDATE_ACCOUNT_INFO, { idToken: token, email: email, returnSecureToken: true }) res.value res end |
#change_password(token, password) ⇒ Net::HTTPOK
Change a user’s password.
58 59 60 61 62 |
# File 'lib/firebase/authentication/service.rb', line 58 def change_password(token, password) res = fetch(:post, Config::UPDATE_ACCOUNT_INFO, { idToken: token, passsord: password, returnSecureToken: true }) res.value res end |
#delete_account(token) ⇒ Net::HTTPOK
Delete a user.
75 76 77 78 79 |
# File 'lib/firebase/authentication/service.rb', line 75 def delete_account(token) res = fetch(:post, Config::DELETE_ACCOUNT, { idToken: token }) res.value res end |
#exchange_custom_token(token) ⇒ Net::HTTPOK
Exchange a custom Auth token for an ID and refresh token
92 93 94 95 96 |
# File 'lib/firebase/authentication/service.rb', line 92 def exchange_custom_token(token) res = fetch(:post, Config::VERIFY_CUSTOM_TOKEN, { idToken: token, returnSecureToken: true }) res.value res end |
#get_account_info(token) ⇒ Net::HTTPOK
Get a user’s data
109 110 111 112 113 |
# File 'lib/firebase/authentication/service.rb', line 109 def get_account_info(token) res = fetch(:post, Config::GET_ACCOUNT_INFO, { idToken: token }) res.value res end |
#send_password_reset_email(email) ⇒ Net::HTTPOK
Send a password reset email.
126 127 128 129 130 |
# File 'lib/firebase/authentication/service.rb', line 126 def send_password_reset_email(email) res = fetch(:post, Config::RESET_PASSWORD, { requestType: "PASSWORD_RESET", email: email }) res.value res end |
#sign_in_email(email, password) ⇒ Net::HTTPOK
Signin a user.
145 146 147 148 149 |
# File 'lib/firebase/authentication/service.rb', line 145 def sign_in_email(email, password) res = fetch(:post, Config::SIGN_IN_EMAIL, { email: email, passsord: password, returnSecureToken: true }) res.value res end |
#sign_up(email, password) ⇒ Net::HTTPOK
Signup new user.
164 165 166 167 168 |
# File 'lib/firebase/authentication/service.rb', line 164 def sign_up(email, password) res = fetch(:post, Config::SIGN_UP_EMAIL, { email: email, password: password, returnSecureToken: true }) res.value res end |