Skip to content

Commit

Permalink
feat: Use alovoa-expo as official frontend for the web #284
Browse files Browse the repository at this point in the history
  • Loading branch information
Nonononoki authored Dec 20, 2023
1 parent 7af0cde commit 8ff8757
Show file tree
Hide file tree
Showing 110 changed files with 1,139 additions and 9,799 deletions.
30 changes: 30 additions & 0 deletions scripts/root/etc/apache2/sites-available/app.alovoa.com.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<VirtualHost *:80>
ServerName app.alovoa.com
Redirect permanent / https://app.alovoa.com/
RewriteEngine on
RewriteCond %{SERVER_NAME} =app.alovoa.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:80>
ServerName www.app.alovoa.com
Redirect permanent / https://app.alovoa.com/
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.app.alovoa.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerName app.alovoa.com
SSLEngine On
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
ProxyPass / https://127.0.0.1:10080/
ProxyPassReverse / https://127.0.0.1:10080/
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
ProxyPreserveHost On
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/alovoa.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/alovoa.com/privkey.pem
</VirtualHost>
30 changes: 30 additions & 0 deletions scripts/root/etc/apache2/sites-available/beta.app.alovoa.com.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<VirtualHost *:80>
ServerName beta.app.alovoa.com
Redirect permanent / https://beta.app.alovoa.com/
RewriteEngine on
RewriteCond %{SERVER_NAME} =beta.app.alovoa.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:80>
ServerName www.beta.app.alovoa.com
Redirect permanent / https://beta.app.alovoa.com/
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.beta.app.alovoa.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerName beta.app.alovoa.com
SSLEngine On
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
ProxyPass / https://127.0.0.1:10081/
ProxyPassReverse / https://127.0.0.1:10081/
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
ProxyPreserveHost On
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/alovoa.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/alovoa.com/privkey.pem
</VirtualHost>
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers("/password/**").permitAll().requestMatchers("/favicon.ico").permitAll().requestMatchers("/sw.js")
.permitAll().requestMatchers("/robots.txt").permitAll().requestMatchers("/.well-known/assetlinks.json")
.permitAll().requestMatchers("/text/*").permitAll().requestMatchers("/manifest/**").permitAll()
.requestMatchers("/fonts/**").permitAll().requestMatchers("/error").permitAll()
.requestMatchers("/fonts/**").permitAll().requestMatchers("/error").permitAll().requestMatchers("/info").permitAll()
.requestMatchers("/user/delete-account-confirm").permitAll()

.anyRequest().authenticated().and().formLogin().loginPage("/login").and().logout()
.deleteCookies(COOKIE_SESSION, COOKIE_REMEMBER).logoutUrl("/logout").logoutSuccessUrl("/?logout").and()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import java.util.List;

@Controller
public class SearchResource {
public class AdminSearchResource {

public static final String URL = "/search";
public static final String URL = "/admin-search";
@Autowired
private AuthService authService;
@Autowired
Expand All @@ -42,45 +42,22 @@ public class SearchResource {
private int donationModulus;
@Value("${app.donation.popup.time}")
private int donationPopupTime;
@Value("${app.search.max.distance}")
private int searchMaxDistance;


@GetMapping(URL)
public ModelAndView search() throws AlovoaException, InvalidKeyException, IllegalBlockSizeException,
BadPaddingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException,
UnsupportedEncodingException {
User user = authService.getCurrentUser(true);

if (!user.isAdmin() && user.getProfilePicture() == null && user.getDescription() == null) {
return new ModelAndView("redirect:" + ProfileOnboardingResource.URL);
if (!user.isAdmin()) {
throw new AlovoaException("not authorized");
}

user.setNumberSearches(user.getNumberSearches() + 1);
userRepo.saveAndFlush(user);

boolean showDonationPopup = false;
if (user.getNumberSearches() % donationModulus == 0) {

List<UserDonation> userDonations = user.getDonations();
if (userDonations != null && !userDonations.isEmpty()) {
UserDonation lastDonation = Collections.max(userDonations, Comparator.comparing(UserDonation::getDate));
Date date = new Date();
long ms = lastDonation.getDate().getTime();
long diff = date.getTime() - ms;

if (diff >= donationPopupTime) {
showDonationPopup = true;
}
} else {
showDonationPopup = true;
}
}

ModelAndView mav = new ModelAndView("search");
ModelAndView mav = new ModelAndView("admin-search");
mav.addObject("user", UserDto.userToUserDto(user, user, userService, textEncryptor, UserDto.NO_MEDIA));
mav.addObject("showDonationPopup", showDonationPopup);
mav.addObject("searchMaxDistance", searchMaxDistance);
return mav;
}
}
Loading

0 comments on commit 8ff8757

Please sign in to comment.