protected override XElement[] Do(WebContext context) { if(context.session.id.ToString().ToLower() != context.httprequest.QueryString["sessionKey"].ToLower()) { throw new FLocalException("Wrong session id"); } context.session.delete(); HttpCookie sessionCookie = context.createCookie(Config.instance.CookiesPrefix + "_session"); sessionCookie.Value = ""; sessionCookie.Expires = DateTime.Now.AddDays(-1); context.httpresponse.AppendCookie(sessionCookie); context.session = null; return new XElement[0]; }
protected override XElement[] Do(WebContext context) { if(Config.instance.IsMigrationEnabled) { try { Account tmpAccount = Account.LoadByName(context.httprequest.Form["name"]); if(tmpAccount.needsMigration) { throw new RedirectException("/My/Login/MigrateAccount/" + context.httprequest.Form["name"]); } } catch(NotFoundInDBException) { } } Account account = Account.tryAuthorize(context.httprequest.Form["name"], context.httprequest.Form["password"]); Session session = Session.create(account); HttpCookie sessionCookie = context.createCookie(Config.instance.CookiesPrefix + "_session"); sessionCookie.Value = session.sessionKey; sessionCookie.Expires = DateTime.Now.AddSeconds(Config.instance.SessionLifetime); context.httpresponse.AppendCookie(sessionCookie); context.session = session; return new XElement[0]; }