Skip to content

Commit 133ffbf

Browse files
committed
add method to create user
1 parent 0cc8c0e commit 133ffbf

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lib/firebase_token_auth/admin_client.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ def update_existing_account(uid, attributes)
2020
service.set_account_info(request)
2121
end
2222

23+
def create_account(email, password, attributes)
24+
params = { email: email, password: password}.merge!(permit_attributes(attributes))
25+
request = Google::Apis::IdentitytoolkitV3::SignupNewUserRequest.new(**params)
26+
service.signup_new_user(request)
27+
end
28+
2329
def delete_existing_account(uid)
2430
update_params = { local_id: uid }
2531
request = Google::Apis::IdentitytoolkitV3::DeleteAccountRequest.new(**update_params)

lib/firebase_token_auth/client.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def user_search_by_email(email)
5555
admin_client.get_account_info({ email: [email] })&.users&.map(&:to_h)
5656
end
5757

58+
def signup_user(email, password, attribute_hash)
59+
admin_client.create_account(email, password, attribute_hash).to_h
60+
end
61+
5862
def user_search_by_uid(uid)
5963
admin_client.get_account_info({ local_id: [uid] })&.users&.map(&:to_h)
6064
end

lib/firebase_token_auth/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module FirebaseTokenAuth
2-
VERSION = '1.3.0'.freeze
2+
VERSION = '1.3.1'.freeze
33
end

0 commit comments

Comments
 (0)