Skip to content

Commit

Permalink
Workaround, refresh page on 403 error in profile and search. Update S…
Browse files Browse the repository at this point in the history
…pring.
  • Loading branch information
Nonononoki committed Oct 29, 2021
1 parent 3088c71 commit dac792e
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.3</version>
<version>2.5.6</version>
<relativePath />
</parent>
<groupId>com.alovoa</groupId>
Expand Down
Expand Up @@ -44,7 +44,8 @@ public class CaptchaService {

public Captcha generate() throws NoSuchAlgorithmException, IOException {

Captcha oldCaptcha = captchaRepo.findByHashCode(getIpHash(request.getRemoteAddr()));
String ipHash = getIpHash(request.getRemoteAddr());
Captcha oldCaptcha = captchaRepo.findByHashCode(ipHash);
if (oldCaptcha != null) {
captchaRepo.delete(oldCaptcha);
captchaRepo.flush();
Expand All @@ -59,7 +60,7 @@ public Captcha generate() throws NoSuchAlgorithmException, IOException {
captcha.setDate(new Date());
captcha.setImage(encoded);
captcha.setText(ox.getText());
captcha.setHashCode(getIpHash(request.getRemoteAddr()));
captcha.setHashCode(ipHash);
captcha = captchaRepo.saveAndFlush(captcha);
return captcha;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Expand Up @@ -32,7 +32,8 @@ spring.security.oauth2.client.registration.google.scope[1]=profile
spring.security.oauth2.client.registration.facebook.scope[0]=email
spring.security.oauth2.client.registration.facebook.scope[1]=public_profile

server.servlet.session.timeout=24h
server.servlet.session.timeout=1h
server.servlet.session.cookie.max-age=1h

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
Expand Down
55 changes: 55 additions & 0 deletions src/main/resources/static/js/profile.js
Expand Up @@ -66,6 +66,9 @@ $(function() {
console.log(e);
hideLoader();
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand Down Expand Up @@ -97,6 +100,10 @@ $(function() {
console.log(e);
hideLoader();
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}

}
});
}
Expand Down Expand Up @@ -136,6 +143,9 @@ $(function() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}, timeoutDescription);
Expand Down Expand Up @@ -186,6 +196,9 @@ $(function() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand All @@ -211,6 +224,9 @@ $(function() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand Down Expand Up @@ -240,6 +256,9 @@ $(function() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand All @@ -262,6 +281,9 @@ $(function() {
error: function() {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
});
Expand All @@ -282,6 +304,9 @@ $(function() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
});
Expand All @@ -301,6 +326,9 @@ $(function() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
});
Expand Down Expand Up @@ -338,6 +366,9 @@ $(function() {
console.log(e);
hideLoader();
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand All @@ -359,6 +390,9 @@ function deleteAudio() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand All @@ -377,6 +411,9 @@ function deleteInterest(id) {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand All @@ -395,6 +432,9 @@ function deleteImage(id) {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand All @@ -413,6 +453,9 @@ function updateAccentColor(color) {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand All @@ -431,6 +474,9 @@ function updateUiDesign() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand All @@ -449,6 +495,9 @@ function updateShowZodiac() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand All @@ -467,6 +516,9 @@ function updateUnits() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand Down Expand Up @@ -522,6 +574,9 @@ function updateProfileWarning() {
error: function(e) {
console.log(e);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});

Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/static/js/search.js
Expand Up @@ -147,6 +147,9 @@ function likeUser(idEnc) {
console.log(e);
hideProfileTile(idEnc);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});

Expand All @@ -166,6 +169,9 @@ function hideUser(idEnc) {
console.log(e);
hideProfileTile(idEnc);
alert(getGenericErrorText());
if(e.status == 403) {
location.reload();
}
}
});
}
Expand Down

0 comments on commit dac792e

Please sign in to comment.