Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 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,18 @@ 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)
service.delete_account(request)
end

private

def permit_attributes(attr_hash)
Expand Down
8 changes: 8 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 All @@ -63,6 +67,10 @@ def update_user(uid, attribute_hash)
admin_client.update_existing_account(uid, attribute_hash).to_h
end

def delete_user(uid)
admin_client.delete_existing_account(uid).to_h
end

private

def admin_client
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please exclude this change.
I'll change version number by myself after add some test code.

VERSION = '1.3.1'.freeze
end