LoginEntrypoint.vala 898 B

1234567891011121314151617181920212223242526272829
  1. using Spry;
  2. using Spry.Authentication;
  3. using Statum;
  4. namespace ClankerSaddle {
  5. /** Public data of the login page's `page` slot. */
  6. public class LoginPagePublic : Object {
  7. public Statum.Model.ActionDto login { get; set; }
  8. }
  9. /**
  10. * Entrypoint for /login: hydrates the page slot with the
  11. * {@link LoginAction} reference; authenticated visitors are sent
  12. * straight to the dashboard.
  13. */
  14. public class LoginEntrypoint : StatumEntrypoint {
  15. public override async DirectiveBuilder handle() throws GLib.Error {
  16. if (!SpryAuth.current(request).is_anonymous) {
  17. return directives().navigate("/");
  18. }
  19. var page = new LoginPagePublic();
  20. page.login = action_registry.author<LoginAction>();
  21. return directives().set_typed<LoginPagePublic>("page", Scope.PAGE, page);
  22. }
  23. }
  24. }