1) A simple way pseudo code to generate regCodes:
for (i=0; i<5;i++)
{
string code = Rand.String(Rand.Next(4, 7)).ToUpper();
// Replace O and I with characters that aren't so confusing
code = code.Replace("O", "X");
code = code.Replace("I", "Y");
bool found = dbLookup("select "+code+" from registeringCodes")
if (!found)
{
dbInsert("insert into registeringCodes set regCode="+code)
break;
}
}
return code
6) When membership expires remove the Device Service Token associated with the users account from the "valid DST tokens" table used for authentication. This is the table that associates that DST with a user account.