Commit 9e0d84c6 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

#3 Improved error messages

parent 271a2230
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@ export default {
  mounted: function() {
    var self = this;
    document.addEventListener('apiError', function(event) {
      self.$bvToast.toast(event.message, {
        title: "Error",
      self.$bvToast.toast(event.message.body, {
        title: event.message.title,
        variant: 'danger',
        solid: true
      });
+4 −8
Original line number Diff line number Diff line
@@ -26,15 +26,11 @@ function apiRequest(url, options, showLoading = true) {
}

function dispatchApiErrorEvent(error) {
  let message;
  if (error.message) {
    message = error.message;
  } else {
    message = 'Generic error';
  }

  let event = new CustomEvent('apiError');
  event.message = message;
  event.message = {
    title: error.error || 'Error',
    body: error.message || 'Unknown error'
  };
  document.dispatchEvent(event);
}

+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.7.RELEASE</version>
        <version>2.2.7.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>it.inaf.ia2</groupId>
+10 −2
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.oauth2.provider.token.store.jwk.JwkTokenStore;
import org.springframework.security.web.authentication.Http403ForbiddenEntryPoint;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
@@ -45,14 +47,20 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    public void configure(HttpSecurity http) throws Exception {

        super.configure(http);

        // CORS are necessary only for development (API access from npm server)
        if (Arrays.asList(env.getActiveProfiles()).contains("dev")) {
            http.authorizeRequests()
                    .antMatchers(HttpMethod.OPTIONS, "/**").permitAll();
        }

        super.configure(http);

        // avoid displaying the annoying BasicAuth browser popup when the
        // session expires (this should happen mostly during development)
        // [401 WWW-Authenticate is converted to 403]
        http.exceptionHandling().defaultAuthenticationEntryPointFor(
                new Http403ForbiddenEntryPoint(), new AntPathRequestMatcher("/keepAlive"));

        http.csrf().disable();
    }

+1 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public class HomePageController {
    private InvitedRegistrationManager invitedRegistrationManager;

    @ResponseBody
    @GetMapping(value = "/home", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @GetMapping(value = "/home", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<HomePageResponse> getMainPage(@Valid GroupsRequest request) {

        HomePageResponse response = new HomePageResponse();
@@ -56,7 +56,6 @@ public class HomePageController {
        if (optReg.isPresent()) {
            request.setAttribute("invited-registration", optReg.get());
            return "/registration-completed";
            //request.getRequestDispatcher("/registration-completed").forward(request, response);
        }

        return "index.html";
Loading