Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
abeb6053
Unverified
Commit
abeb6053
authored
Sep 25, 2018
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
#12527
parent
b1ebbbda
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
14 deletions
+44
-14
src/main/java/org/b3log/solo/processor/console/common/ProcessAuthAdvice.java
...3log/solo/processor/console/common/ProcessAuthAdvice.java
+11
-5
src/main/webapp/error/401.ftl
src/main/webapp/error/401.ftl
+28
-0
src/main/webapp/error/403.ftl
src/main/webapp/error/403.ftl
+2
-4
src/main/webapp/error/404.ftl
src/main/webapp/error/404.ftl
+1
-1
src/main/webapp/error/500.ftl
src/main/webapp/error/500.ftl
+2
-4
No files found.
src/main/java/org/b3log/solo/processor/console/common/ProcessAuthAdvice.java
View file @
abeb6053
...
...
@@ -21,9 +21,10 @@ import org.b3log.latke.ioc.LatkeBeanManager;
import
org.b3log.latke.ioc.Lifecycle
;
import
org.b3log.latke.ioc.inject.Named
;
import
org.b3log.latke.ioc.inject.Singleton
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.advice.BeforeRequestProcessAdvice
;
import
org.b3log.latke.servlet.advice.RequestProcessAdviceException
;
import
org.b3log.solo.service.UserQueryService
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -35,22 +36,27 @@ import java.util.Map;
*
* @author <a href="mailto:wmainlove@gmail.com">Love Yao</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.
0, Sep 5, 2017
* @version 1.0.1.
1, Sep 25, 2018
*/
@Named
@Singleton
public
class
ProcessAuthAdvice
extends
BeforeRequestProcessAdvice
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ProcessAuthAdvice
.
class
);
@Override
public
void
doAdvice
(
final
HTTPRequestContext
context
,
final
Map
<
String
,
Object
>
args
)
throws
RequestProcessAdviceException
{
public
void
doAdvice
(
final
HTTPRequestContext
context
,
final
Map
<
String
,
Object
>
args
)
{
final
LatkeBeanManager
beanManager
=
Lifecycle
.
getBeanManager
();
final
UserQueryService
userQueryService
=
beanManager
.
getReference
(
UserQueryService
.
class
);
if
(!
userQueryService
.
is
LoggedIn
(
context
.
getRequest
(),
context
.
getResponse
()))
{
if
(!
userQueryService
.
is
AdminLoggedIn
(
context
.
getRequest
()))
{
try
{
context
.
getResponse
().
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
}
catch
(
final
IOException
e
)
{
throw
new
RuntimeException
(
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Response sends error failed"
,
e
);
}
}
}
...
...
src/main/webapp/error/401.ftl
0 → 100644
View file @
abeb6053
<#--
Solo - A small and beautiful blogging system written in Java.
Copyright (c) 2010-2018, b3log.org & hacpai.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<#include "../macro-common-page.ftl">
<@commonPage "401 Unauthorized!">
<h2>401 Unauthorized!</h2>
<img class="img-error" src="${staticServePath}/images/403.png" alt="401" title="401 Unauthorized!" />
<div class="a-error">
Please <a href="${loginURL}">Login</a> or return to <a href="${servePath}">Index</a>.
</div>
</@commonPage>
src/main/webapp/error/403.ftl
View file @
abeb6053
...
...
@@ -21,10 +21,8 @@
<@commonPage "403 Forbidden!">
<h2>403 Forbidden!</h2>
<img class="img-error" src="${staticServePath}/images/403.png" alt="403
: forbidden" title="403: forbidden
" />
<img class="img-error" src="${staticServePath}/images/403.png" alt="403
" title="403 Forbidden!
" />
<div class="a-error">
Please
<a href="${loginURL}">Login</a>.
Return to <a href="${servePath}">Index</a> or <a href="https://hacpai.com">HacPai</a>.
Please <a href="${loginURL}">Login</a> or return to <a href="${servePath}">Index</a>.
</div>
</@commonPage>
src/main/webapp/error/404.ftl
View file @
abeb6053
...
...
@@ -23,6 +23,6 @@
<h2>404 Not Found!</h2>
<img class="img-error" src="${staticServePath}/images/404.gif" title="404" alt="404 Not Found!"/>
<div class="a-error">
Return to <a href="${servePath}">Index</a> or <a href="https://hacpai.com">HacPai
</a>.
Please <a href="${loginURL}">Login</a> or return to <a href="${servePath}">Index
</a>.
</div>
</@commonPage>
\ No newline at end of file
src/main/webapp/error/500.ftl
View file @
abeb6053
...
...
@@ -21,10 +21,8 @@
<@commonPage "500 Internal Server Error!">
<h2>500 Internal Server Error!</h2>
<img class="img-error" src="${staticServePath}/images/500.png" title="500
: internal error" alt="500: internal error"
/>
<img class="img-error" src="${staticServePath}/images/500.png" title="500
" alt="500 Internal Server Error!"
/>
<div class="a-error">
Please
<a href="https://github.com/b3log/solo/issues/new">report</a>.
Return to <a href="${servePath}">Index</a> or <a href="https://hacpai.com">HacPai</a>.
Please <a href="https://github.com/b3log/solo/issues/new">report</a> it or return to <a href="${servePath}">Index</a>.
</div>
</@commonPage>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment