<?php

namespace Modules\User\Contracts;

use Modules\User\Entities\Role;
use Modules\User\Entities\User;
use Cartalyst\Sentinel\Activations\ActivationInterface;

interface Authentication
{
    /**
     * Authenticate a user.
     *
     * @param array $credentials
     * @param bool $remember
     *
     * @return mixed
     */
    public function login($credentials, $remember = false);


    /**
     * Register a new user.
     *
     * @param array $data
     *
     * @return bool
     */
    public function register($data);


    /**
     * Register and activate a new user.
     *
     * @param array $data
     *
     * @return User
     */
    public function registerAndActivate($data);


    /**
     * Activate the given used id.
     *
     * @param int $userId
     * @param string $code
     *
     * @return mixed
     */
    public function activate($userId, $code);


    /**
     * Assign a role to the given user.
     *
     * @param User $user
     * @param Role $role
     *
     * @return void
     */
    public function assignRole(User $user, Role $role);


    /**
     * Log the user out of the application.
     *
     * @return bool
     */
    public function logout();


    /**
     * Create an activation code for the given user.
     *
     * @param User $user
     *
     * @return ActivationInterface
     */
    public function createActivation(User $user);


    /**
     * Create a reminders code for the given user.
     *
     * @param User $user
     *
     * @return string
     */
    public function createReminderCode(User $user);


    /**
     * Completes the reset password process.
     *
     * @param User $user
     * @param string $code
     * @param string $password
     *
     * @return bool
     */
    public function completeResetPassword(User $user, $code, $password);


    /**
     * Determines if the current user has access to the given permissions.
     *
     * @param array|string $permissions
     *
     * @return bool
     */
    public function hasAccess($permissions);


    /**
     * Determine if the user has access to any given permissions
     *
     * @param array|string $permissions
     *
     * @return bool
     */
    public function hasAnyAccess($permissions);


    /**
     * Check if the user is logged in.
     *
     * @return bool
     */
    public function check();


    /**
     * Get the currently logged-in user.
     *
     * @return User
     */
    public function user();


    /**
     * Get the ID for the currently authenticated user.
     *
     * @return int|null
     */
    public function id();
}
