class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable,
         :registerable,
         :recoverable,
         :rememberable,
         :trackable,
         :validatable

  has_many :tasks
  has_many :posts
  belongs_to :team

  validates :email, presence: true, uniqueness: true
  validates :first_name, :last_name, presence: true

  def user_name
    first_name + " " + last_name
  end

  def author(task)
    task.user_id == current_user.id
  end
end
