Class: FirebaseAuth::User

Inherits:
Object
  • Object
show all
Defined in:
lib/firebase_auth/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, user_id) ⇒ User



5
6
7
8
# File 'lib/firebase_auth/user.rb', line 5

def initialize(email, user_id)
  self.email = email
  self.user_id = user_id
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/firebase_auth/user.rb', line 3

def email
  @email
end

#user_idObject

Returns the value of attribute user_id.



3
4
5
# File 'lib/firebase_auth/user.rb', line 3

def user_id
  @user_id
end

Class Method Details

.authenticate_user(id_token, project_id) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/firebase_auth/user.rb', line 10

def self.authenticate_user(id_token, project_id)
  auth_service = FirebaseAuth.new(project_id)
  decoded_token = auth_service.verify_id_token(id_token)
  return nil unless decoded_token

  email = decoded_token["email"]
  # In a real-world application, you should lookup the user in your database
  # and validate the password or other credentials.
  User.new(email, self.user_id) # Password is not returned from Firebase
end