using System.IdentityModel.Tokens.Jwt;
using adas_core.Authentication.Models;
using adas_core.Domain.Models.DTO;
using adas_core.Domain.Models.Filter;
using adas_core.Domain.Models.MongoModels;
using adas_core.Domain.Models.Responses;
using Microsoft.IdentityModel.Tokens;
using MongoDB.Bson;

namespace adas_core.Authentication.Interfaces;

public interface IUserService
{
    static readonly string TokenTypeUser = "user";
    static readonly string TokenTypeRefresh = "refresh";

    Task<TokenResult> Login(string username, string password);
    Task<User> GetUser(string username, string password);
    Task<TokenResult> RefreshToken(string refreshToken);

    Task<TokenResult> LoginWithAccessToken(string token);
    void ValidateToken(string token, string tokenType, out SecurityToken securityToken);
    Task<User?> GetUserByToken(JwtSecurityToken? jwtToken);
    Task<User?> GetUserByCasTicket(string service, string ticket);
    Task<TokenResult> GenerateJwt(User user);
    Task<List<User>> GetAll();
    Task<User?> GetUserById(ObjectId id);
    Task<User?> GetUserByUserName(string name);
    Task<User?> GetUserByName(string name);
    Task<User?> CreateUser(User userEntryLdap);
    Task<User?> CreateNewUserByRequest(User user);

    Task<User?> CreateNewUserWithAuthorities(CreateUserWithAuthDto createUserWithAuthDto);
    Task<User?> UpdateUserWithAuthorities(UpdateUserWithAuthDto createUserWithAuthDto, bool updatePass);
    Task<User?> UpdateUsersByRequest(User user, bool updatePass);
    Task<bool> UpdateUserPassword(ObjectId id, string oldPassword, string newPassword);
    Task<bool> DeleteUser(ObjectId id);
    Task<PaginationResponse<User>> GetPaginatedUsers(PaginationFilter config);
    Task<Authorization> CreateNewAuthority(Authorization auth);
    Task<bool> DeleteAuthority(string id);
    Task<bool> UpdateAuthority(Authorization authorization);
    Task<TokenResult> LoginWithGivenAccessToken(string token);
}