Beispiel #1
0
        protected override Account DoCreateAccount(WebContext context)
        {
            if (Config.instance.IsMigrationEnabled)
            {
                try {
                    Account tmpAccount = Account.LoadByName(context.httprequest.Form["login"]);
                    if (tmpAccount.needsMigration)
                    {
                        throw new RedirectException("/My/Login/MigrateAccount/" + context.httprequest.Form["login"]);
                    }
                } catch (NotFoundInDBException) {
                }
            }

            Invite invite = Invite.LoadById(int.Parse(context.httprequest.Form["inviteId"]));

            if (invite.isUsed)
            {
                throw new FLocalException("Invite is already used");
            }
            if (context.httprequest.Form["password"] != context.httprequest.Form["password2"])
            {
                throw new FLocalException("Passwords mismatch");
            }
            return(invite.createAccount(context.httprequest.Form["code"], context.httprequest.Form["login"], context.httprequest.Form["password"], context.httprequest.UserHostAddress, context.httprequest.Form["registrationEmail"]));
        }
Beispiel #2
0
        protected override IEnumerable <XElement> getSpecificData(WebContext context)
        {
            string[] parts    = this.url.remainder.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            int      inviteId = int.Parse(parts[0]);
            string   code     = parts[1];
            Invite   invite   = Invite.LoadById(inviteId);

            if (invite.isUsed)
            {
                throw new FLocalException("Invite is already used");
            }
            if (invite.code != code)
            {
                throw new FLocalException("Code mismatch");
            }
            return(new XElement[] {
                invite.exportToXml(context),
            });
        }