Created
June 16, 2020 20:42
-
-
Save furkankaplan/734223d217f34bc4d24f5091c9cbb20c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// LoginInteractor.swift | |
// reserve-ios | |
// | |
// Created by Furkan Kaplan on 6.06.2020. | |
// Copyright © 2020 Furkan Kaplan. All rights reserved. | |
// | |
import Foundation | |
import Firebase | |
class LoginInteractor: BaseInteractor, LoginInteractorProtocol { | |
var presenter: LoginInteractorOutputProtocol? | |
func loginUser(phone: String?, password: String?) { | |
guard let phone = phone else { return } | |
guard let password = password else { return } | |
database.child(FirebaseEndPointConstants.usersTable).observeSingleEvent(of: .childAdded) { (data) in | |
guard let value = data.value as? [String: Any] else { return } | |
// do { | |
// let decoder = JSONDecoder() | |
// decoder.dateDecodingStrategy = .iso8601 | |
// | |
// let jsonData = try JSONSerialization.data(withJSONObject: data.value, options: [.prettyPrinted]) | |
// let groceryItem = try decoder.decode(UserModel.self, from: jsonData) | |
// | |
// print(groceryItem) | |
// } catch let error { | |
// print(error) | |
// } | |
value.convertTo(object: UserModel.self) | |
} | |
// Log in the user and redirect to Dashboard | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment