package com.telephoners.krakyournet.ctf.repositories;

import com.telephoners.krakyournet.ctf.beans.User;
import io.dropwizard.auth.basic.BasicCredentials;
import org.ektorp.CouchDbConnector;

public class UsersRepository extends Repository<User>
{
    public UsersRepository(Class<User> type, CouchDbConnector connector)
    {
        super(type, connector);
    }

    public User getUserByName(String username)
    {
        return null;
        /*
        return datastore.createQuery(User.class)
                .field("name").equal(username)
                .asList()
                .stream()
                .findFirst()
                .orElseThrow(UserNotFoundException::new);*/
    }

    public User authenticateUser(BasicCredentials basicCredentials)
    {
        return null;
        /*
        return datastore.createQuery(User.class)
                .field("name").equal(basicCredentials.getUsername())
                .field("password").equal(Hex.encodeHexString(messageDigestProvider.getMessageDigest().digest(basicCredentials.getPassword().getBytes())))
                .get();*/
    }
}
