Skip to content

Commit

Permalink
add method to create user
Browse files Browse the repository at this point in the history
  • Loading branch information
abuzzell committed Nov 25, 2021
1 parent 0cc8c0e commit 133ffbf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/firebase_token_auth/admin_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def update_existing_account(uid, attributes)
service.set_account_info(request)
end

def create_account(email, password, attributes)
params = { email: email, password: password}.merge!(permit_attributes(attributes))
request = Google::Apis::IdentitytoolkitV3::SignupNewUserRequest.new(**params)
service.signup_new_user(request)
end

def delete_existing_account(uid)
update_params = { local_id: uid }
request = Google::Apis::IdentitytoolkitV3::DeleteAccountRequest.new(**update_params)
Expand Down
4 changes: 4 additions & 0 deletions lib/firebase_token_auth/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def user_search_by_email(email)
admin_client.get_account_info({ email: [email] })&.users&.map(&:to_h)
end

def signup_user(email, password, attribute_hash)
admin_client.create_account(email, password, attribute_hash).to_h
end

def user_search_by_uid(uid)
admin_client.get_account_info({ local_id: [uid] })&.users&.map(&:to_h)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/firebase_token_auth/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module FirebaseTokenAuth
VERSION = '1.3.0'.freeze
VERSION = '1.3.1'.freeze
end

0 comments on commit 133ffbf

Please sign in to comment.