Class: AuthRepository

Inherits:
Ibrain::BaseRepository
  • Object
show all
Defined in:
app/repositories/auth_repository.rb

Instance Method Summary collapse

Constructor Details

#initialize(record, params) ⇒ AuthRepository

Returns a new instance of AuthRepository.



6
7
8
9
10
11
# File 'app/repositories/auth_repository.rb', line 6

def initialize(record, params)
  super(nil, record)

  @params = params
  @collection = Ibrain.user_class
end

Instance Method Details

#createObject



13
14
15
16
17
18
19
# File 'app/repositories/auth_repository.rb', line 13

def create
  user = collection.new(provider: 'manual')
  user.assign_attributes(normalize_params.except(:id_token))
  user.save!

  user
end

#sign_inObject



21
22
23
24
25
26
27
28
# File 'app/repositories/auth_repository.rb', line 21

def 
  return firebase_verify if is_social?

  user = collection.ibrain_find(manual_params, available_columns)
  return unless user.try(:valid_password?, manual_params[:password])

  user
end