import { Injectable } from '@angular/core';
import * as Parse from "parse"

@Injectable({
  providedIn: 'root'
})
export class UserService {
  get currentUser() {
    try {
      let currentUser = JSON.parse(localStorage.getItem("USER_AUTH") || "")
      return currentUser
    } catch (err) { }
    return {}
  }
  set currentUser(v) {
    localStorage.setItem("USER_AUTH", JSON.stringify(v))
  }
  constructor() { }


  async checkUserPassword(user: {
    username: string
    password: string
  }) {

    let exists = await Parse.User.logIn(user?.username, user?.password)
    if (exists?.id) {
      return true
    }
    return false
  }
}
