Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Codebot.Web;
- namespace Codebot.Blob.Web
- {
- public class HomePage : PageHandler
- {
- private FileManager manager;
- public Global App { get { return Context.ApplicationInstance as Global; } }
- public FileUser User { get { return Context.User as FileUser; } }
- protected override void Run()
- {
- manager = new FileManager(this);
- base.Run();
- }
- protected override void EmptyPage()
- {
- var url = PathAndQuery;
- if (url.Path == "/" || url.Path == "/home.ashx")
- {
- ContentType = "text/html";
- if (User.IsAnonymous)
- Include("/pages/login.html", true);
- else
- Include("/pages/manager.html", true);
- return;
- }
- manager.ProcessPage(url);
- }
- private void WriteStatus(bool passed)
- {
- Write(passed ? "OK" : "FAIL");
- }
- [MethodPage("login")]
- public void LoginMethod()
- {
- var status = User.Login(App, Read("name"), Read("password"), Request.UserAgent);
- WriteStatus(status);
- }
- [MethodPage("logout")]
- public void LogoutMethod()
- {
- User.Logout(App);
- Redirect("/");
- }
- [MethodPage("adduser")]
- public void AddUserMethod()
- {
- var status =App.AddUser(Read("name"), Read("password"));
- WriteStatus(status);
- }
- [MethodPage("deleteuser")]
- public void DeleteUserMethod()
- {
- var status = App.DeleteUser(Read("name");
- WriteStatus(status);
- }
- [MethodPage("files")]
- public void FilesMethod()
- {
- manager.ProcessAction();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement