1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 
<?php

declare(strict_types=1);

namespace Wtf\Auth\Repository;

use Wtf\Root;

interface RepositoryInterface
{
    /**
     * Get user by login.
     *
     * @return null|RepositoryInterface
     */
    public function getByLogin(string $login): ?Root;

    /**
     * Get login fields, eg: ['email', 'username'].
     *
     * @return array
     */
    public function getLoginFields(): array;

    /**
     * Check if provided login and password are correct and return matched user
     * Otherwise, return null if no user found or password incorrect.
     *
     * @return null|Root
     */
    public function login(string $login, string $password): ?Root;

    /**
     * Generate special code for user who forgot password.
     *
     * @return string code
     */
    public function forgot(string $login): string;

    /**
     * Reset user password by code.
     *
     * @param string $code         Return value of self::forgot()
     * @param string $new_password New password for user
     *
     * @return bool
     */
    public function reset(string $code, string $new_password): bool;
}