Skip to content

Commit

Permalink
automatic project update
Browse files Browse the repository at this point in the history
  • Loading branch information
jdubois committed Dec 27, 2017
1 parent bbfb4cf commit 66e1436
Show file tree
Hide file tree
Showing 80 changed files with 418 additions and 246 deletions.
6 changes: 4 additions & 2 deletions .yo-rc.json
Expand Up @@ -23,14 +23,16 @@
"en"
],
"serverPort": 8080,
"jhipsterVersion": "4.13.0",
"jhipsterVersion": "4.13.1",
"enableSocialSignIn": false,
"useSass": false,
"jhiPrefix": "jhi",
"messageBroker": false,
"serviceDiscoveryType": false,
"clientPackageManager": "yarn",
"clientFramework": "angularX",
"jwtSecretKey": "07a00779cfd8d372c73b40631b62c81503e1b18e"
"jwtSecretKey": "07a00779cfd8d372c73b40631b62c81503e1b18e",
"cacheProvider": "ehcache",
"enableHibernateCache": true
}
}
14 changes: 7 additions & 7 deletions README.md
@@ -1,5 +1,5 @@
# jhipsterSampleApplication
This application was generated using JHipster 4.13.0, you can find documentation and help at [http://www.jhipster.tech/documentation-archive/v4.13.0](http://www.jhipster.tech/documentation-archive/v4.13.0).
This application was generated using JHipster 4.13.1, you can find documentation and help at [http://www.jhipster.tech/documentation-archive/v4.13.1](http://www.jhipster.tech/documentation-archive/v4.13.1).

## Development

Expand Down Expand Up @@ -152,13 +152,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.

[JHipster Homepage and latest documentation]: http://www.jhipster.tech
[JHipster 4.13.0 archive]: http://www.jhipster.tech/documentation-archive/v4.13.0
[JHipster 4.13.1 archive]: http://www.jhipster.tech/documentation-archive/v4.13.1

[Using JHipster in development]: http://www.jhipster.tech/documentation-archive/v4.13.0/development/
[Using Docker and Docker-Compose]: http://www.jhipster.tech/documentation-archive/v4.13.0/docker-compose
[Using JHipster in production]: http://www.jhipster.tech/documentation-archive/v4.13.0/production/
[Running tests page]: http://www.jhipster.tech/documentation-archive/v4.13.0/running-tests/
[Setting up Continuous Integration]: http://www.jhipster.tech/documentation-archive/v4.13.0/setting-up-ci/
[Using JHipster in development]: http://www.jhipster.tech/documentation-archive/v4.13.1/development/
[Using Docker and Docker-Compose]: http://www.jhipster.tech/documentation-archive/v4.13.1/docker-compose
[Using JHipster in production]: http://www.jhipster.tech/documentation-archive/v4.13.1/production/
[Running tests page]: http://www.jhipster.tech/documentation-archive/v4.13.1/running-tests/
[Setting up Continuous Integration]: http://www.jhipster.tech/documentation-archive/v4.13.1/setting-up-ci/

[Gatling]: http://gatling.io/
[Node.js]: https://nodejs.org/
Expand Down
13 changes: 8 additions & 5 deletions package.json
Expand Up @@ -21,7 +21,7 @@
"core-js": "2.4.1",
"font-awesome": "4.7.0",
"jquery": "3.2.1",
"ng-jhipster": "0.3.4",
"ng-jhipster": "0.3.5",
"ngx-cookie": "2.0.1",
"ngx-infinite-scroll": "0.5.1",
"ngx-webstorage": "2.0.1",
Expand All @@ -48,7 +48,7 @@
"exports-loader": "0.6.4",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"generator-jhipster": "4.13.0",
"generator-jhipster": "4.13.1",
"html-loader": "0.5.0",
"html-webpack-plugin": "2.30.1",
"jasmine-core": "2.7.0",
Expand All @@ -71,15 +71,15 @@
"proxy-middleware": "0.15.0",
"rimraf": "2.6.1",
"sourcemap-istanbul-instrumenter-loader": "0.2.0",
"string-replace-webpack-plugin": "0.1.3",
"style-loader": "0.18.2",
"to-string-loader": "1.1.5",
"ts-node": "3.3.0",
"tslint": "5.5.0",
"tslint-loader": "3.5.3",
"typescript": "2.5.3",
"xml2js": "0.4.17",
"uglifyjs-webpack-plugin": "1.1.2",
"uglifyjs-webpack-plugin": "1.1.4",
"uglify-es": "3.2.2",
"webpack": "3.10.0",
"webpack-dev-server": "2.9.5",
"webpack-merge": "4.1.1",
Expand All @@ -89,11 +89,14 @@
"workbox-webpack-plugin": "2.1.2",
"write-file-webpack-plugin": "4.1.0"
},
"resolutions": {
"uglify-es": "3.2.2"
},
"engines": {
"node": ">=6.9.0"
},
"scripts": {
"lint": "tslint --project './tsconfig.json' -e 'node_modules/**'",
"lint": "tslint --project tsconfig.json -e 'node_modules/**'",
"lint:fix": "yarn run lint -- --fix",
"ngc": "ngc -p tsconfig-aot.json",
"cleanup": "rimraf target/{aot,www}",
Expand Down
8 changes: 6 additions & 2 deletions pom.xml
Expand Up @@ -13,7 +13,7 @@
<maven.version>3.0.0</maven.version>
<java.version>1.8</java.version>
<scala.version>2.12.1</scala.version>
<node.version>v8.9.1</node.version>
<node.version>v8.9.3</node.version>
<yarn.version>v1.3.2</yarn.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand All @@ -29,7 +29,7 @@
<profile.swagger />

<!-- Dependency versions -->
<jhipster-dependencies.version>0.1.4</jhipster-dependencies.version>
<jhipster-dependencies.version>0.1.5</jhipster-dependencies.version>
<!-- The spring-boot version should match the one managed by
https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster-dependencies.version} -->
<spring-boot.version>1.5.9.RELEASE</spring-boot.version>
Expand Down Expand Up @@ -99,6 +99,10 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>io.github.jhipster</groupId>
<artifactId>jhipster</artifactId>
Expand Down
Expand Up @@ -37,7 +37,8 @@ public CacheConfiguration(JHipsterProperties jHipsterProperties) {
@Bean
public JCacheManagerCustomizer cacheManagerCustomizer() {
return cm -> {
cm.createCache("users", jcacheConfiguration);
cm.createCache(io.github.jhipster.sample.repository.UserRepository.USERS_BY_LOGIN_CACHE, jcacheConfiguration);
cm.createCache(io.github.jhipster.sample.repository.UserRepository.USERS_BY_EMAIL_CACHE, jcacheConfiguration);
cm.createCache(io.github.jhipster.sample.domain.User.class.getName(), jcacheConfiguration);
cm.createCache(io.github.jhipster.sample.domain.Authority.class.getName(), jcacheConfiguration);
cm.createCache(io.github.jhipster.sample.domain.User.class.getName() + ".authorities", jcacheConfiguration);
Expand Down
Expand Up @@ -6,7 +6,7 @@
public final class Constants {

// Regex for acceptable logins
public static final String LOGIN_REGEX = "^[_'.@A-Za-z0-9-]*$";
public static final String LOGIN_REGEX = "^[_'.A-Za-z0-9-]*$";

public static final String SYSTEM_ACCOUNT = "system";
public static final String ANONYMOUS_USER = "anonymoususer";
Expand Down
Expand Up @@ -21,8 +21,6 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.SQLException;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.FilterType;

@Configuration
@EnableJpaRepositories("io.github.jhipster.sample.repository")
Expand Down
@@ -1,6 +1,7 @@
package io.github.jhipster.sample.repository;

import io.github.jhipster.sample.domain.User;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -17,6 +18,10 @@
@Repository
public interface UserRepository extends JpaRepository<User, Long> {

String USERS_BY_LOGIN_CACHE = "usersByLogin";

String USERS_BY_EMAIL_CACHE = "usersByEmail";

Optional<User> findOneByActivationKey(String activationKey);

List<User> findAllByActivatedIsFalseAndCreatedDateBefore(Instant dateTime);
Expand All @@ -31,8 +36,12 @@ public interface UserRepository extends JpaRepository<User, Long> {
Optional<User> findOneWithAuthoritiesById(Long id);

@EntityGraph(attributePaths = "authorities")
@Cacheable(cacheNames = "users")
@Cacheable(cacheNames = USERS_BY_LOGIN_CACHE)
Optional<User> findOneWithAuthoritiesByLogin(String login);

@EntityGraph(attributePaths = "authorities")
@Cacheable(cacheNames = USERS_BY_EMAIL_CACHE)
Optional<User> findOneWithAuthoritiesByEmail(String email);

Page<User> findAllByLoginNot(Pageable pageable, String login);
}
Expand Up @@ -34,18 +34,24 @@ public DomainUserDetailsService(UserRepository userRepository) {
public UserDetails loadUserByUsername(final String login) {
log.debug("Authenticating {}", login);
String lowercaseLogin = login.toLowerCase(Locale.ENGLISH);
Optional<User> userFromDatabase = userRepository.findOneWithAuthoritiesByLogin(lowercaseLogin);
return userFromDatabase.map(user -> {
if (!user.getActivated()) {
throw new UserNotActivatedException("User " + lowercaseLogin + " was not activated");
}
List<GrantedAuthority> grantedAuthorities = user.getAuthorities().stream()
.map(authority -> new SimpleGrantedAuthority(authority.getName()))
.collect(Collectors.toList());
return new org.springframework.security.core.userdetails.User(lowercaseLogin,
user.getPassword(),
grantedAuthorities);
}).orElseThrow(() -> new UsernameNotFoundException("User " + lowercaseLogin + " was not found in the " +
"database"));
Optional<User> userByEmailFromDatabase = userRepository.findOneWithAuthoritiesByEmail(lowercaseLogin);
return userByEmailFromDatabase.map(user -> createSpringSecurityUser(lowercaseLogin, user)).orElseGet(() -> {
Optional<User> userByLoginFromDatabase = userRepository.findOneWithAuthoritiesByLogin(lowercaseLogin);
return userByLoginFromDatabase.map(user -> createSpringSecurityUser(lowercaseLogin, user))
.orElseThrow(() -> new UsernameNotFoundException("User " + lowercaseLogin + " was not found in the " +
"database"));
});
}

private org.springframework.security.core.userdetails.User createSpringSecurityUser(String lowercaseLogin, User user) {
if (!user.getActivated()) {
throw new UserNotActivatedException("User " + lowercaseLogin + " was not activated");
}
List<GrantedAuthority> grantedAuthorities = user.getAuthorities().stream()
.map(authority -> new SimpleGrantedAuthority(authority.getName()))
.collect(Collectors.toList());
return new org.springframework.security.core.userdetails.User(user.getLogin(),
user.getPassword(),
grantedAuthorities);
}
}
32 changes: 21 additions & 11 deletions src/main/java/io/github/jhipster/sample/service/UserService.java
@@ -1,5 +1,6 @@
package io.github.jhipster.sample.service;

import io.github.jhipster.sample.config.CacheConfiguration;
import io.github.jhipster.sample.domain.Authority;
import io.github.jhipster.sample.domain.User;
import io.github.jhipster.sample.repository.AuthorityRepository;
Expand All @@ -9,7 +10,6 @@
import io.github.jhipster.sample.security.SecurityUtils;
import io.github.jhipster.sample.service.util.RandomUtil;
import io.github.jhipster.sample.service.dto.UserDTO;
import io.github.jhipster.sample.web.rest.vm.ManagedUserVM;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -35,8 +35,6 @@ public class UserService {

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

private static final String USERS_CACHE = "users";

private final UserRepository userRepository;

private final PasswordEncoder passwordEncoder;
Expand All @@ -59,7 +57,8 @@ public Optional<User> activateRegistration(String key) {
// activate given user for the registration key.
user.setActivated(true);
user.setActivationKey(null);
cacheManager.getCache(USERS_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
log.debug("Activated user: {}", user);
return user;
});
Expand All @@ -74,7 +73,8 @@ public Optional<User> completePasswordReset(String newPassword, String key) {
user.setPassword(passwordEncoder.encode(newPassword));
user.setResetKey(null);
user.setResetDate(null);
cacheManager.getCache(USERS_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
return user;
});
}
Expand All @@ -85,7 +85,8 @@ public Optional<User> requestPasswordReset(String mail) {
.map(user -> {
user.setResetKey(RandomUtil.generateResetKey());
user.setResetDate(Instant.now());
cacheManager.getCache(USERS_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
return user;
});
}
Expand All @@ -111,6 +112,8 @@ public User registerUser(UserDTO userDTO, String password) {
authorities.add(authority);
newUser.setAuthorities(authorities);
userRepository.save(newUser);
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(newUser.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(newUser.getEmail());
log.debug("Created Information for User: {}", newUser);
return newUser;
}
Expand Down Expand Up @@ -139,6 +142,8 @@ public User createUser(UserDTO userDTO) {
user.setResetDate(Instant.now());
user.setActivated(true);
userRepository.save(user);
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
log.debug("Created Information for User: {}", user);
return user;
}
Expand All @@ -161,7 +166,8 @@ public void updateUser(String firstName, String lastName, String email, String l
user.setEmail(email);
user.setLangKey(langKey);
user.setImageUrl(imageUrl);
cacheManager.getCache(USERS_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
log.debug("Changed Information for User: {}", user);
});
}
Expand All @@ -188,7 +194,8 @@ public Optional<UserDTO> updateUser(UserDTO userDTO) {
userDTO.getAuthorities().stream()
.map(authorityRepository::findOne)
.forEach(managedAuthorities::add);
cacheManager.getCache(USERS_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
log.debug("Changed Information for User: {}", user);
return user;
})
Expand All @@ -198,7 +205,8 @@ public Optional<UserDTO> updateUser(UserDTO userDTO) {
public void deleteUser(String login) {
userRepository.findOneByLogin(login).ifPresent(user -> {
userRepository.delete(user);
cacheManager.getCache(USERS_CACHE).evict(login);
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
log.debug("Deleted User: {}", user);
});
}
Expand All @@ -209,7 +217,8 @@ public void changePassword(String password) {
.ifPresent(user -> {
String encryptedPassword = passwordEncoder.encode(password);
user.setPassword(encryptedPassword);
cacheManager.getCache(USERS_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
log.debug("Changed password for User: {}", user);
});
}
Expand Down Expand Up @@ -245,7 +254,8 @@ public void removeNotActivatedUsers() {
for (User user : users) {
log.debug("Deleting not activated user {}", user.getLogin());
userRepository.delete(user);
cacheManager.getCache(USERS_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
}
}

Expand Down
@@ -1,16 +1,13 @@
package io.github.jhipster.sample.web.rest.vm;

import io.github.jhipster.sample.config.Constants;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
* View Model object for storing a user's credentials.
*/
public class LoginVM {

@Pattern(regexp = Constants.LOGIN_REGEX)
@NotNull
@Size(min = 1, max = 50)
private String username;
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/account/activate/activate.service.ts
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { Http, Response, URLSearchParams } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { Observable } from 'rxjs/Observable';
import { SERVER_API_URL } from '../../app.constants';

@Injectable()
Expand Down
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { Observable } from 'rxjs/Observable';
import { SERVER_API_URL } from '../../../app.constants';

@Injectable()
Expand Down
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { Observable } from 'rxjs/Observable';
import { SERVER_API_URL } from '../../../app.constants';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/account/password/password.service.ts
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { Observable } from 'rxjs/Observable';
import { SERVER_API_URL } from '../../app.constants';

@Injectable()
Expand Down

0 comments on commit 66e1436

Please sign in to comment.