{"size": 997, "ext": "js", "max_stars_repo_path": "src/handlers/user.js", "max_stars_repo_name": "SyedBilal1349/todoapp-server", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/handlers/user.js", "max_issues_repo_name": "SyedBilal1349/todoapp-server", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/handlers/user.js", "max_forks_repo_name": "SyedBilal1349/todoapp-server", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.3170731707, "max_line_length": 112, "alphanum_fraction": 0.6148445336}
// Imports
const fire = require('../firebase/index')

// User Registration
exports.registerUser = async (req, res) => {
  const userObj = req.body
  const email = userObj.email
  const password = userObj.password
  if (email && password) {
    fire.fbase.auth().createUserWithEmailAndPassword(email, password).then(user => {  // Firebase sign in method
      if (user) {
        res.send(user)
      }
      else {
        res.send("cant create user")
      }
    })
  }
  else {
    res.send("please provide complete info")
  }
}

// Reset Password Through Email
exports.resetPassword = async (req, res) => {
  const userObj = req.body
  const email = userObj.email
  if (email) {
    fire.fbase.auth().sendPasswordResetEmail(email).then(link => {   // Firebase reset password method
      if (link) {
        res.send("Password reset link sent")
      }
      else {
        res.send("cant reset password")
      }
    })
  }
  else {
    res.send("please provide email to reset password")
  }
}