File tree Expand file tree Collapse file tree
java/com/raysmond/blog/support/web
resources/templates/layout Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ I recommend you import the source code into Intellij IDE to edit the code.
77773 . Open the project in Intellij IDEA.
78784 . Run ` SpringBlogApplication.java ` as Java application.
79795 . Preview: http://localhost:8080
80- Admin: http://localhost:900 /admin , the default admin account is: admin@admin.com , password: admin
80+ Admin: http://localhost:8080 /admin , the default admin account is: ` admin ` , password: ` admin `
8181
8282
8383> Lombok is required to run the project. You can install the plugin in Intellij IDEA.
@@ -91,9 +91,10 @@ I recommend you import the source code into Intellij IDE to edit the code.
9191- Run it (Java8 is a must)
9292
9393 ```
94- # assuming you have the jar and yml files under current dir
94+ java -jar SpringBlog-0.1.jar --spring.profiles.active=prod
95+ # OR with external spring profile file
9596 java -jar SpringBlog-0.1.jar --spring.config.location=application-production.yml
9697 ```
9798
9899## License
99- Modified BSD license. Copyright (c) 2015, Jiankun LEI (Raysmond).
100+ Modified BSD license. Copyright (c) 2015 - 2018 , Jiankun LEI (Raysmond).
Original file line number Diff line number Diff line change 44 * @author Raysmond
55 */
66public interface SyntaxHighlightService {
7- public String highlight (String content );
7+ String highlight (String content );
88}
Original file line number Diff line number Diff line change 11package com .raysmond .blog .support .web ;
22
3-
43import com .domingosuarez .boot .autoconfigure .jade4j .JadeHelper ;
54import com .raysmond .blog .services .AppSetting ;
5+
66import org .springframework .beans .factory .annotation .Autowired ;
7+ import org .springframework .security .authentication .AnonymousAuthenticationToken ;
8+ import org .springframework .security .core .Authentication ;
9+ import org .springframework .security .core .context .SecurityContextHolder ;
710import org .springframework .stereotype .Service ;
811
912import java .text .SimpleDateFormat ;
@@ -24,6 +27,18 @@ public class ViewHelper {
2427 private String applicationEnv ;
2528 private long startTime ;
2629
30+ /**
31+ * Check if current user is authenticated
32+ *
33+ * @return true/false
34+ */
35+ public boolean isLogin () {
36+ Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
37+ return null != authentication
38+ && authentication .isAuthenticated ()
39+ && !(authentication instanceof AnonymousAuthenticationToken );
40+ }
41+
2742 @ Autowired
2843 public ViewHelper (AppSetting appSetting ) {
2944 this .appSetting = appSetting ;
Original file line number Diff line number Diff line change @@ -8,4 +8,6 @@ nav.navbar.navbar-bright
88 li: a( href ="/tags" ) Tags
99 li: a( href ="/posts/projects" ) Projects
1010 li: a( href ="/about" ) About
11+ if viewHelper .isLogin ()
12+ li: a( href ="/admin" ) Administration
1113
You can’t perform that action at this time.
0 commit comments