<file_sep>//
//  FeedVC.swift
//  WestPluto1
//
//  Created by <NAME> on 1/17/18.
//  Copyright © 2018 <NAME>. All rights reserved.
//

import UIKit
import Firebase
import CoreFoundation
import AVFoundation
import FirebaseDatabase
import SwiftKeychainWrapper

func admin() {
    
   
}



class FeedVC: UITableViewController {
    
    
    
    
    @IBOutlet weak var WhatIamConsideringBuying: UITextField!
    
    @IBOutlet weak var Education: UITextField!
    
 
   
    
    
    
    
    override func viewDidLoad() {
       
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Sign Out", style: .plain, target: self, action: #selector(signOut))
   
        super.viewDidLoad()
        
    
        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem
        
    
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    //override func didReceiveMemoryWarning() {
       // super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
   // }


    // MARK: - Table view data source

    //override func numberOfSections(in tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        //return 1
   // }

   // override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        //return 5
  // }
    
    //override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
       // return UITableViewCell()
    //}
    
    

@IBAction func SubmitPressed(_ sender: Any) {

        let databaseRef = Database.database().reference()
        let uid = Auth.auth().currentUser!.uid
        databaseRef.child("Education").child(uid).setValue(self.Education.text!)
        // The following line will save it in userDefault itself. And you dont have to call the whole UserDefault Everywhere
        databaseRef.child("WhatIamConsideringBuying").child(uid).setValue(self.WhatIamConsideringBuying.text!)
        self.performSegue(withIdentifier: "tohome", sender: nil)
        
    
    
    }
    
    func getUsers(){
        
        usersCollection.getEducation{ (snapshot, _) in
            
            let Education = snapshot!.Education
        
        
        
        
    }
    }
   
    @objc func signOut (_sender: AnyObject) {
        

            
        KeychainWrapper.standard.removeObject(forKey: "uid")
        do {
            try Auth.auth().signOut()
        } catch let signOutError as NSError {
            print ("Error signing out: %@", signOutError)
        }
        
        dismiss(animated: true, completion: nil)
            
        }

}


<file_sep>//
//  File.swift
//  WestPluto1
//
//  Created by <NAME> on 2018/03/10.
//  Copyright © 2018 <NAME>. All rights reserved.
//

import Foundation
<file_sep>//
//  ViewController.swift
//  WestPluto1
//
//  Created by <NAME> on 1/5/18.
//  Copyright © 2018 <NAME>. All rights reserved.
//

import UIKit
import Firebase
import SwiftKeychainWrapper


class ViewController: UIViewController {
    
    
    @IBOutlet weak var emailField: UITextField!
    
    @IBOutlet weak var passwordField: UITextField!
    
    var userUID: String!
    
    override func viewDidLoad() {
       
        super.viewDidLoad()
        
    }
    
    override func viewDidAppear(_ animated: Bool) {
        if let _ = KeychainWrapper.standard.string(forKey: "uid") {
            self.performSegue(withIdentifier: "tohome", sender: nil)
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
   
    
    
    
    @IBAction func signInPressed(_ sender: Any) {
        if let email = emailField.text, let password = passwordField.text {
            Auth.auth().createUser(withEmail: email, password: <PASSWORD>) { (user, error) in
                Auth.auth().signIn(withEmail: email, password: <PASSWORD>) { (user, error) in
                    
                    
                if let userID = user?.uid {
                    KeychainWrapper.standard.set((userID), forKey: "uid")
                    self.performSegue(withIdentifier: "tohome", sender: nil) }
                if error != nil{
                    print("Incorrect")
                    let alert = UIAlertController(title: "Error", message: "Incorrect Email or Password.", preferredStyle: UIAlertControllerStyle.alert)
                    let action = UIAlertAction(title: "Ok", style: .default, handler: nil)
                    alert.addAction(action)
                    self.present(alert, animated: true, completion: nil)
                }
                else {
                    if let userID = user?.uid {
                        KeychainWrapper.standard.set((userID), forKey: "uid")
                        self.performSegue(withIdentifier: "tohome", sender: nil)
                        
                            let databaseRef = Database.database().reference()
                        databaseRef.child("users").child(userID).setValue(self.emailField.text!)
                        
                        
                    
                    
                    }
                }
            }
        }
    }
}
}
<file_sep>//
//  Constants.swift
//  WestPluto1
//
//  Created by <NAME> on 5/28/19.
//  Copyright © 2019 <NAME>. All rights reserved.
//


import Foundation
import UIKit
import SwiftKeychainWrapper
import Firebase
import CoreFoundation
import AVFoundation
import FirebaseDatabase


var educationCache : String {
    get {
        return (UserDefaults.standard.string(forKey: "Education")!)
    } set {
        UserDefaults.standard.set(newValue, forKey: "Education")
    }
}

var WhatIamConsideringBuyingCache : String {
    get {
        return (UserDefaults.standard.string(forKey: "WhatIamConsideringBuying")!)
    } set {
        UserDefaults.standard.set(newValue, forKey: "WhatIamConsideringBuying")
    }
}






<file_sep>//
//  homepage.swift
//  WestPluto1
//
//  Created by <NAME> on 5/21/19.
//  Copyright © 2019 <NAME>. All rights reserved.
//

import Foundation
import UIKit
import SwiftKeychainWrapper
import Firebase
import CoreFoundation
import AVFoundation
import FirebaseDatabase




class homepage:UITableViewController {
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
       if snapshot.exists()
                    self.performSegue(withIdentifier: "toFeed", sender: nil)
        

    }
    
 override func viewDidLoad() {
    
    navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Sign Out", style: .plain, target: self, action: #selector(signOut))
    super.viewDidLoad()
}

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    

  
 
    
    @objc func signOut (_sender: AnyObject) {
        
        
        KeychainWrapper.standard.removeObject(forKey: "uid")
        do {
            try Auth.auth().signOut()
        } catch let signOutError as NSError {
            print ("Error signing out: %@", signOutError)
        }
        
        dismiss(animated: true, completion: nil)
        
    }

}

