Skip to content

Commit

Permalink
automatic project update
Browse files Browse the repository at this point in the history
  • Loading branch information
jdubois committed May 3, 2018
1 parent 41c36c1 commit a2d81ec
Show file tree
Hide file tree
Showing 251 changed files with 6,663 additions and 6,790 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Original file line Diff line number Diff line change
@@ -1 +1,2 @@
node_modules node_modules
target
10 changes: 8 additions & 2 deletions .prettierrc
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,12 @@
# Prettier configuration # Prettier configuration

printWidth: 140 printWidth: 140
singleQuote: true singleQuote: true
jsxBracketSameLine: false tabWidth: 4
parser: typescript useTabs: false

# js and ts rules:
arrowParens: avoid arrowParens: avoid

# jsx and tsx rules:
jsxBracketSameLine: false
2 changes: 1 addition & 1 deletion .yo-rc.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"en" "en"
], ],
"serverPort": 8080, "serverPort": 8080,
"jhipsterVersion": "5.0.0-beta.0", "jhipsterVersion": "5.0.0-beta.1",
"enableSocialSignIn": false, "enableSocialSignIn": false,
"useSass": false, "useSass": false,
"jhiPrefix": "jhi", "jhiPrefix": "jhi",
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
# jhipsterSampleApplication # jhipsterSampleApplication
This application was generated using JHipster 5.0.0-beta.0, you can find documentation and help at [https://www.jhipster.tech/documentation-archive/v5.0.0-beta.0](https://www.jhipster.tech/documentation-archive/v5.0.0-beta.0). This application was generated using JHipster 5.0.0-beta.1, you can find documentation and help at [https://www.jhipster.tech/documentation-archive/v5.0.0-beta.1](https://www.jhipster.tech/documentation-archive/v5.0.0-beta.1).


## Development ## Development


Expand Down Expand Up @@ -151,13 +151,13 @@ For more information refer to [Using Docker and Docker-Compose][], this page als
To configure CI for your project, run the ci-cd sub-generator (`jhipster ci-cd`), this will let you generate configuration files for a number of Continuous Integration systems. Consult the [Setting up Continuous Integration][] page for more information. To configure CI for your project, run the ci-cd sub-generator (`jhipster ci-cd`), this will let you generate configuration files for a number of Continuous Integration systems. Consult the [Setting up Continuous Integration][] page for more information.


[JHipster Homepage and latest documentation]: https://www.jhipster.tech [JHipster Homepage and latest documentation]: https://www.jhipster.tech
[JHipster 5.0.0-beta.0 archive]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.0 [JHipster 5.0.0-beta.1 archive]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.1


[Using JHipster in development]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.0/development/ [Using JHipster in development]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.1/development/
[Using Docker and Docker-Compose]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.0/docker-compose [Using Docker and Docker-Compose]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.1/docker-compose
[Using JHipster in production]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.0/production/ [Using JHipster in production]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.1/production/
[Running tests page]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.0/running-tests/ [Running tests page]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.1/running-tests/
[Setting up Continuous Integration]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.0/setting-up-ci/ [Setting up Continuous Integration]: https://www.jhipster.tech/documentation-archive/v5.0.0-beta.1/setting-up-ci/


[Gatling]: http://gatling.io/ [Gatling]: http://gatling.io/
[Node.js]: https://nodejs.org/ [Node.js]: https://nodejs.org/
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
"@angular/platform-browser": "5.2.8", "@angular/platform-browser": "5.2.8",
"@angular/platform-browser-dynamic": "5.2.8", "@angular/platform-browser-dynamic": "5.2.8",
"@angular/router": "5.2.8", "@angular/router": "5.2.8",
"@fortawesome/fontawesome": "1.1.5",
"@fortawesome/fontawesome-free-solid": "5.0.10",
"@ng-bootstrap/ng-bootstrap": "1.0.1", "@ng-bootstrap/ng-bootstrap": "1.0.1",
"bootstrap": "4.0.0", "bootstrap": "4.0.0",
"core-js": "2.5.3", "core-js": "2.5.3",
"font-awesome": "4.7.0",
"jquery": "3.3.1", "jquery": "3.3.1",
"moment": "2.21.0", "moment": "2.21.0",
"ng-jhipster": "0.4.5", "ng-jhipster": "0.4.5",
Expand Down Expand Up @@ -50,7 +51,7 @@
"extract-text-webpack-plugin": "4.0.0-beta.0", "extract-text-webpack-plugin": "4.0.0-beta.0",
"file-loader": "1.1.11", "file-loader": "1.1.11",
"fork-ts-checker-webpack-plugin": "0.4.1", "fork-ts-checker-webpack-plugin": "0.4.1",
"generator-jhipster": "5.0.0-beta.0", "generator-jhipster": "5.0.0-beta.1",
"html-loader": "0.5.5", "html-loader": "0.5.5",
"html-webpack-plugin": "3.0.6", "html-webpack-plugin": "3.0.6",
"husky": "0.14.3", "husky": "0.14.3",
Expand All @@ -69,22 +70,22 @@
"lint-staged": "7.0.0", "lint-staged": "7.0.0",
"merge-jsons-webpack-plugin": "1.0.14", "merge-jsons-webpack-plugin": "1.0.14",
"prettier": "1.11.1", "prettier": "1.11.1",
"puppeteer": "1.1.1",
"protractor": "5.1.2", "protractor": "5.1.2",
"protractor-jasmine2-screenshot-reporter": "0.4.0", "protractor-jasmine2-screenshot-reporter": "0.4.0",
"proxy-middleware": "0.15.0", "proxy-middleware": "0.15.0",
"puppeteer": "1.1.1",
"rimraf": "2.6.1", "rimraf": "2.6.1",
"sourcemap-istanbul-instrumenter-loader": "0.2.0", "sourcemap-istanbul-instrumenter-loader": "0.2.0",
"style-loader": "0.20.3", "style-loader": "0.20.3",
"tapable": "1.0.0", "tapable": "1.0.0",
"thread-loader": "1.1.5",
"to-string-loader": "1.1.5", "to-string-loader": "1.1.5",
"ts-node": "5.0.1", "ts-node": "5.0.1",
"ts-loader": "4.0.1", "ts-loader": "4.0.1",
"tslint": "5.9.1", "tslint": "5.9.1",
"tslint-config-prettier": "1.9.0", "tslint-config-prettier": "1.9.0",
"tslint-loader": "3.6.0", "tslint-loader": "3.6.0",
"typescript": "2.7.2", "typescript": "2.7.2",
"thread-loader": "1.1.5",
"xml2js": "0.4.19", "xml2js": "0.4.19",
"uglifyjs-webpack-plugin": "1.2.3", "uglifyjs-webpack-plugin": "1.2.3",
"webpack": "4.1.1", "webpack": "4.1.1",
Expand All @@ -100,11 +101,11 @@
"node": ">=8.9.0" "node": ">=8.9.0"
}, },
"lint-staged": { "lint-staged": {
"*.ts": ["prettier --write", "git add"] "src/**/*.{ts,css,scss}": ["prettier --write", "git add"]
}, },
"scripts": { "scripts": {
"precommit": "lint-staged", "precommit": "lint-staged",
"prettier:format":"yarn prettier --write **/*.ts", "prettier:format": "yarn prettier --write 'src/**/*.{ts,css,scss}'",
"lint": "tslint --project tsconfig.json -e 'node_modules/**'", "lint": "tslint --project tsconfig.json -e 'node_modules/**'",
"lint:fix": "yarn run lint -- --fix", "lint:fix": "yarn run lint -- --fix",
"ngc": "ngc -p tsconfig-aot.json", "ngc": "ngc -p tsconfig-aot.json",
Expand Down
27 changes: 10 additions & 17 deletions pom.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@


<repositories> <repositories>
<!-- TODO Remove snapshot repositories after final Spring Boot 2 release --> <!-- TODO Remove snapshot repositories after final Spring Boot 2 release -->
<repository>
<id>sonatype-snapshot</id>
<name>JHipster Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository> <repository>
<id>spring-milestones</id> <id>spring-milestones</id>
<name>Spring Milestones</name> <name>Spring Milestones</name>
Expand All @@ -44,7 +36,7 @@
<maven.version>3.0.0</maven.version> <maven.version>3.0.0</maven.version>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<scala.version>2.12.1</scala.version> <scala.version>2.12.1</scala.version>
<node.version>v8.10.0</node.version> <node.version>v8.11.1</node.version>
<yarn.version>v1.5.1</yarn.version> <yarn.version>v1.5.1</yarn.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand All @@ -60,13 +52,13 @@
<profile.swagger /> <profile.swagger />


<!-- Dependency versions --> <!-- Dependency versions -->
<jhipster-dependencies.version>2.0.0-SNAPSHOT</jhipster-dependencies.version> <jhipster-dependencies.version>2.0.2</jhipster-dependencies.version>
<!-- The spring-boot version should match the one managed by <!-- The spring-boot version should match the one managed by
https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster-dependencies.version} --> https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster-dependencies.version} -->
<spring-boot.version>2.0.0.RELEASE</spring-boot.version> <spring-boot.version>2.0.1.RELEASE</spring-boot.version>
<!-- The hibernate version should match the one managed by <!-- The hibernate version should match the one managed by
https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster-dependencies.version} --> https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/${spring-boot.version} -->
<hibernate.version>5.2.14.Final</hibernate.version> <hibernate.version>5.2.16.Final</hibernate.version>
<!-- The javassist version should match the one managed by <!-- The javassist version should match the one managed by
https://mvnrepository.com/artifact/org.hibernate/hibernate-core/${hibernate.version} --> https://mvnrepository.com/artifact/org.hibernate/hibernate-core/${hibernate.version} -->
<javassist.version>3.22.0-GA</javassist.version> <javassist.version>3.22.0-GA</javassist.version>
Expand Down Expand Up @@ -129,6 +121,11 @@
</dependencyManagement> </dependencyManagement>


<dependencies> <dependencies>
<dependency>
<groupId>io.github.jhipster</groupId>
<artifactId>jhipster-framework</artifactId>
</dependency>

<!-- TODO To remove after final Spring Boot 2 release --> <!-- TODO To remove after final Spring Boot 2 release -->
<dependency> <dependency>
<groupId>javax.xml.bind</groupId> <groupId>javax.xml.bind</groupId>
Expand All @@ -139,10 +136,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId> <artifactId>spring-boot-starter-cache</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.github.jhipster</groupId>
<artifactId>jhipster</artifactId>
</dependency>
<dependency> <dependency>
<groupId>io.dropwizard.metrics</groupId> <groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId> <artifactId>metrics-core</artifactId>
Expand Down
13 changes: 11 additions & 2 deletions src/main/docker/.dockerignore
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,14 @@
# https://docs.docker.com/engine/reference/builder/#dockerignore-file # https://docs.docker.com/engine/reference/builder/#dockerignore-file
# by default ignore everything except the jar file classes/
**/* generated-sources/
generated-test-sources/
h2db/
maven-archiver/
maven-status/
reports/
surefire-reports/
test-classes/
test-results/
www/
!*.jar !*.jar
!*.war !*.war
1 change: 1 addition & 0 deletions src/main/docker/app.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
jhipstersampleapplication-app: jhipstersampleapplication-app:
image: jhipstersampleapplication image: jhipstersampleapplication
environment: environment:
# - _JAVA_OPTIONS=-Xmx512m -Xms256m
- SPRING_PROFILES_ACTIVE=prod,swagger - SPRING_PROFILES_ACTIVE=prod,swagger
- SPRING_DATASOURCE_URL=jdbc:mysql://jhipstersampleapplication-mysql:3306/jhipstersampleapplication?useUnicode=true&characterEncoding=utf8&useSSL=false - SPRING_DATASOURCE_URL=jdbc:mysql://jhipstersampleapplication-mysql:3306/jhipstersampleapplication?useUnicode=true&characterEncoding=utf8&useSSL=false
- JHIPSTER_SLEEP=10 # gives time for the database to boot before the application - JHIPSTER_SLEEP=10 # gives time for the database to boot before the application
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/io/github/jhipster/sample/ApplicationWebXml.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.github.jhipster.sample;

import io.github.jhipster.sample.config.DefaultProfileUtil;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

/**
* This is a helper Java class that provides an alternative to creating a web.xml.
* This will be invoked only when the application is deployed to a Servlet container like Tomcat, JBoss etc.
*/
public class ApplicationWebXml extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
/**
* set a default to use when no profile is configured.
*/
DefaultProfileUtil.addDefaultProfile(application.application());
return application.sources(JhipsterSampleApplicationApp.class);
}
}
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import liquibase.integration.spring.SpringLiquibase; import liquibase.integration.spring.SpringLiquibase;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties; import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
Expand All @@ -21,8 +20,6 @@
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;


import javax.sql.DataSource; import javax.sql.DataSource;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.SQLException; import java.sql.SQLException;


@Configuration @Configuration
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ private void addLogstashAppender(LoggerContext context) {
String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}"; String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";


// More documentation is available at: https://github.com/logstash/logstash-logback-encoder // More documentation is available at: https://github.com/logstash/logstash-logback-encoder
LogstashEncoder logstashEncoder=new LogstashEncoder(); LogstashEncoder logstashEncoder = new LogstashEncoder();
// Set the Logstash appender config from JHipster properties // Set the Logstash appender config from JHipster properties
logstashEncoder.setCustomFields(customFields); logstashEncoder.setCustomFields(customFields);
// Set the Logstash appender config from JHipster properties // Set the Logstash appender config from JHipster properties
logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(),jHipsterProperties.getLogging().getLogstash().getPort())); logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(), jHipsterProperties.getLogging().getLogstash().getPort()));


ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter(); ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
throwableConverter.setRootCauseFirst(true); throwableConverter.setRootCauseFirst(true);
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public void init() {
metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet());
if (hikariDataSource != null) { if (hikariDataSource != null) {
log.debug("Monitoring the datasource"); log.debug("Monitoring the datasource");
// remove the factory created by HikariDataSourceMetricsPostProcessor until JHipster migrate to Micrometer
hikariDataSource.setMetricsTrackerFactory(null);
hikariDataSource.setMetricRegistry(metricRegistry); hikariDataSource.setMetricRegistry(metricRegistry);
} }
if (jHipsterProperties.getMetrics().getJmx().isEnabled()) { if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
Expand Down Expand Up @@ -107,9 +107,9 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers("/api/authenticate").permitAll() .antMatchers("/api/authenticate").permitAll()
.antMatchers("/api/account/reset-password/init").permitAll() .antMatchers("/api/account/reset-password/init").permitAll()
.antMatchers("/api/account/reset-password/finish").permitAll() .antMatchers("/api/account/reset-password/finish").permitAll()
.antMatchers("/api/profile-info").permitAll()
.antMatchers("/api/**").authenticated() .antMatchers("/api/**").authenticated()
.antMatchers("/management/health").permitAll() .antMatchers("/management/health").permitAll()
.antMatchers("/management/info").permitAll()
.antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/v2/api-docs/**").permitAll() .antMatchers("/v2/api-docs/**").permitAll()
.antMatchers("/swagger-resources/configuration/ui").permitAll() .antMatchers("/swagger-resources/configuration/ui").permitAll()
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* Configuration of web application with Servlet 3.0 APIs. * Configuration of web application with Servlet 3.0 APIs.
*/ */
@Configuration @Configuration
public class WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer { public class WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> {


private final Logger log = LoggerFactory.getLogger(WebConfigurer.class); private final Logger log = LoggerFactory.getLogger(WebConfigurer.class);


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
@Entity @Entity
@Table(name = "jhi_authority") @Table(name = "jhi_authority")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)

public class Authority implements Serializable { public class Authority implements Serializable {


private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class BankAccount implements Serializable {
private String name; private String name;


@NotNull @NotNull
@Column(name = "balance", precision=10, scale=2, nullable = false) @Column(name = "balance", precision = 10, scale = 2, nullable = false)
private BigDecimal balance; private BigDecimal balance;


@ManyToOne @ManyToOne
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/github/jhipster/sample/domain/Operation.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Operation implements Serializable {
private String description; private String description;


@NotNull @NotNull
@Column(name = "amount", precision=10, scale=2, nullable = false) @Column(name = "amount", precision = 10, scale = 2, nullable = false)
private BigDecimal amount; private BigDecimal amount;


@ManyToOne @ManyToOne
Expand All @@ -46,8 +46,8 @@ public class Operation implements Serializable {
@ManyToMany @ManyToMany
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinTable(name = "operation_label", @JoinTable(name = "operation_label",
joinColumns = @JoinColumn(name="operations_id", referencedColumnName="id"), joinColumns = @JoinColumn(name = "operations_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name="labels_id", referencedColumnName="id")) inverseJoinColumns = @JoinColumn(name = "labels_id", referencedColumnName = "id"))
private Set<Label> labels = new HashSet<>(); private Set<Label> labels = new HashSet<>();


// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
@Table(name = "jhi_persistent_audit_event") @Table(name = "jhi_persistent_audit_event")
public class PersistentAuditEvent implements Serializable { public class PersistentAuditEvent implements Serializable {


private static final long serialVersionUID = 1L;

@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "event_id") @Column(name = "event_id")
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/io/github/jhipster/sample/service/UserService.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -214,19 +214,15 @@ public void changePassword(String currentClearTextPassword, String newPassword)
.flatMap(userRepository::findOneByLogin) .flatMap(userRepository::findOneByLogin)
.ifPresent(user -> { .ifPresent(user -> {
String currentEncryptedPassword = user.getPassword(); String currentEncryptedPassword = user.getPassword();
assertClearTextPasswordMatchesEncryptedPassword(currentClearTextPassword, currentEncryptedPassword); if (!passwordEncoder.matches(currentClearTextPassword, currentEncryptedPassword)) {
throw new InvalidPasswordException();
}
String encryptedPassword = passwordEncoder.encode(newPassword); String encryptedPassword = passwordEncoder.encode(newPassword);
user.setPassword(encryptedPassword); user.setPassword(encryptedPassword);
this.clearUserCaches(user); this.clearUserCaches(user);
log.debug("Changed password for User: {}", user); log.debug("Changed password for User: {}", user);
}); });
} }
private void assertClearTextPasswordMatchesEncryptedPassword(String clearTextPassword, String encryptedPassword) {
if (!passwordEncoder.matches(clearTextPassword,encryptedPassword)){
throw new InvalidPasswordException();
}
}



@Transactional(readOnly = true) @Transactional(readOnly = true)
public Page<UserDTO> getAllManagedUsers(Pageable pageable) { public Page<UserDTO> getAllManagedUsers(Pageable pageable) {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void changePassword(@RequestBody PasswordChangeDTO passwordChangeDto) {
if (!checkPasswordLength(passwordChangeDto.getNewPassword())) { if (!checkPasswordLength(passwordChangeDto.getNewPassword())) {
throw new InvalidPasswordException(); throw new InvalidPasswordException();
} }
userService.changePassword(passwordChangeDto.getCurrentPassword(),passwordChangeDto.getNewPassword()); userService.changePassword(passwordChangeDto.getCurrentPassword(), passwordChangeDto.getNewPassword());
} }


/** /**
Expand Down
Loading

0 comments on commit a2d81ec

Please sign in to comment.