using InABox.API;
using InABox.Core;

namespace InABox.Rpc
{
    public class RpcCheck2FAHandler : RpcCommandHandler<IRpcServer, RpcCheck2FACommand, RpcCheck2FAParameters, RpcCheck2FAResult> 
    {
        protected override RpcCheck2FAResult Execute(IRpcSession session, RpcCheck2FAParameters parameters, Logger logger)
        {
            var result = CredentialsCache.ValidateCode(parameters.SessionId, parameters.Code);

            return new RpcCheck2FAResult() { Valid = result };
        }

        public RpcCheck2FAHandler(IRpcServer sender) : base(sender)
        {
        }
    }
}