You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using FLocal.Core;
|
|
using FLocal.Common;
|
|
using System.Xml.Linq;
|
|
using FLocal.Common.dataobjects;
|
|
|
|
namespace FLocal.IISHandler.handlers.response {
|
|
class MigrateAccountHandler : AbstractGetHandler {
|
|
|
|
protected override string templateName {
|
|
get {
|
|
return "MigrateAccount.xslt";
|
|
}
|
|
}
|
|
|
|
protected override System.Xml.Linq.XElement[] getSpecificData(WebContext context) {
|
|
string username;
|
|
if(context.httprequest.Form["username"] != "") {
|
|
username = context.httprequest.Form["username"];
|
|
} else {
|
|
if(context.requestParts.Length != 2) {
|
|
throw new CriticalException("Username is not specified");
|
|
}
|
|
username = context.requestParts[1];
|
|
}
|
|
Account account = Account.LoadByName(username);
|
|
if(!account.needsMigration) throw new FLocalException("Already migrated");
|
|
string key = Util.RandomString(8, Util.RandomSource.LETTERS_DIGITS);
|
|
return new XElement[] {
|
|
new XElement("migrationInfo",
|
|
new XElement("accountId", account.id),
|
|
new XElement("key", key),
|
|
new XElement("check", Util.md5(key + " " + Config.instance.SaltMigration + " " + account.id))
|
|
),
|
|
};
|
|
}
|
|
|
|
}
|
|
}
|
|
|