Code:
using System;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using LLS;
namespace LLS.Test
{
class Program
{
Client _client;
UserModel UserInfo;
static void Main(string[] args)
{
new Program().Start().Wait();
}
async Task Start()
{
await AuthBasic();
await Task.Delay(-1);
}
async Task AuthBasic()
{
_client = new Client();
var AuthResponse = await _client.Authenticate("Your App Key");
if(AuthResponse.IsError)
{
Console.WriteLine(AuthResponse.Error);
Console.ReadKey();
Environment.Exit(0);
}
var LoginResponse = await _client.Login("email", "password");
if(LoginResponse.IsError)
{
Console.WriteLine(LoginResponse.Error);
Console.ReadKey();
Environment.Exit(0);
}
UserInfo = LoginResponse.Model.User;
if(UserInfo.HasActiveLicense)
{
await ActualProgram();
} else
{
Console.Write("No Active License Detected, want to redeem a working one? (Y/N):");
if(Console.ReadKey().Key == ConsoleKey.Y)
{
Console.Write("Type in your new License: ");
string key = Console.ReadLine();
var RedeemResponse = await _client.Redeem(key);
if(RedeemResponse.IsError)
{
Console.WriteLine(LoginResponse.Error);
Console.ReadKey();
Environment.Exit(0);
}
if(RedeemResponse.Model.IsLifetime || RedeemResponse.Model.EndingAt > DateTime.Now)
{
await ActualProgram();
} else
{
Console.WriteLine("Expired License");
Console.ReadKey();
Environment.Exit(0);
}
} else
{
Console.WriteLine("Exiting in 5 Seconds...");
await Task.Delay(5*1000);
Environment.Exit(0);
}
}
}
async Task ActualProgram()
{
Console.WriteLine("Welcome " + UserInfo.Username + " to " + Assembly.GetExecutingAssembly().FullName);
}
}
}
Uses Auth System from LLS