diff options
Diffstat (limited to 'src/main/java')
3 files changed, 50 insertions, 3 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/login/LoginResource.java b/src/main/java/eu/mulk/mulkcms2/benki/login/LoginResource.java new file mode 100644 index 0000000..53fbcf6 --- /dev/null +++ b/src/main/java/eu/mulk/mulkcms2/benki/login/LoginResource.java @@ -0,0 +1,24 @@ +package eu.mulk.mulkcms2.benki.login; + +import io.quarkus.security.Authenticated; +import java.net.URI; +import java.net.URISyntaxException; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; +import org.jboss.logging.Logger; + +@Path("/login") +public class LoginResource { + + private static final Logger log = Logger.getLogger(LoginResource.class); + + @GET + @Authenticated + public Response getRoot(@HeaderParam("referer") @DefaultValue("/posts") String referer) + throws URISyntaxException { + return Response.seeOther(new URI(referer)).build(); + } +} diff --git a/src/main/java/eu/mulk/mulkcms2/benki/login/LoginStatus.java b/src/main/java/eu/mulk/mulkcms2/benki/login/LoginStatus.java new file mode 100644 index 0000000..06a184c --- /dev/null +++ b/src/main/java/eu/mulk/mulkcms2/benki/login/LoginStatus.java @@ -0,0 +1,23 @@ +package eu.mulk.mulkcms2.benki.login; + +import io.quarkus.qute.TemplateData; +import io.quarkus.security.identity.SecurityIdentity; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; + +@Named("LoginStatus") +@RequestScoped +@TemplateData +public class LoginStatus { + + @Inject SecurityIdentity identity; + + public boolean loggedIn() { + return !identity.isAnonymous(); + } + + public String getUserName() { + return identity.getPrincipal().getName(); + } +} diff --git a/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java b/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java index 2ffcdd5..7b2395d 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java @@ -64,7 +64,7 @@ public class WikiResource { } @GET - @Path("/{pageName}") + @Path("{pageName}") @Produces(TEXT_HTML) @Authenticated public TemplateInstance getPage(@PathParam("pageName") String pageName) { @@ -82,7 +82,7 @@ public class WikiResource { } @POST - @Path("/{pageName}") + @Path("{pageName}") @Authenticated @Transactional @Produces(APPLICATION_JSON) @@ -136,7 +136,7 @@ public class WikiResource { } @GET - @Path("/{pageName}/revisions") + @Path("{pageName}/revisions") @Produces(TEXT_HTML) @Authenticated public TemplateInstance getPageRevisions(@PathParam("pageName") String pageName) { |