mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-24 16:14:26 +08:00
Prevent redirection to another website on login
Affects issues: - Fixed #1717
This commit is contained in:
parent
c44d3d7a7e
commit
bd754c4445
@ -31,8 +31,8 @@ import java.util.Optional;
|
||||
@Singleton
|
||||
public class LoginPageResolver implements NoAuthResolver {
|
||||
|
||||
private ResponseFactory responseFactory;
|
||||
private Lazy<WebServer> webServer;
|
||||
private final ResponseFactory responseFactory;
|
||||
private final Lazy<WebServer> webServer;
|
||||
|
||||
@Inject
|
||||
public LoginPageResolver(
|
||||
@ -47,7 +47,8 @@ public class LoginPageResolver implements NoAuthResolver {
|
||||
public Optional<Response> resolve(Request request) {
|
||||
Optional<WebUser> user = request.getUser();
|
||||
if (user.isPresent() || !webServer.get().isAuthRequired()) {
|
||||
Optional<String> from = request.getQuery().get("from");
|
||||
Optional<String> from = request.getQuery().get("from")
|
||||
.filter(redirectBackTo -> !redirectBackTo.startsWith("http"));
|
||||
return Optional.of(responseFactory.redirectResponse(from.orElse("/")));
|
||||
}
|
||||
return Optional.of(responseFactory.loginPageResponse());
|
||||
|
@ -50,7 +50,7 @@
|
||||
if (json && json.success) {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const cameFrom = urlParams.get('from');
|
||||
window.location.href = cameFrom ? cameFrom : './';
|
||||
window.location.href = cameFrom && !cameFrom.startsWith("http") ? cameFrom : './';
|
||||
} else {
|
||||
return displayError('Login failed: ' + json.error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user