mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 15:25:49 +00:00
fix bug of profile loading
This commit is contained in:
parent
9d7d809515
commit
a175a83f34
7 changed files with 22 additions and 26 deletions
|
@ -11,6 +11,4 @@ import java.io.Serializable;
|
||||||
*/
|
*/
|
||||||
public class RoleDTO extends NamedDTO implements Serializable {
|
public class RoleDTO extends NamedDTO implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,15 +153,15 @@ public class UserDTO extends PersonDTO implements Serializable, UserDetails {
|
||||||
this.roles = roles;
|
this.roles = roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRole(String role){
|
public void addRole(String role) {
|
||||||
if(this.roles==null){
|
if (this.roles == null) {
|
||||||
this.roles = new ArrayList<>();
|
this.roles = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.roles.add(role);
|
this.roles.add(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeRole(String role){
|
public void removeRole(String role) {
|
||||||
this.roles.remove(role);
|
this.roles.remove(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,4 +58,5 @@ public class Role implements Serializable {
|
||||||
public void setUsers(Set<User> users) {
|
public void setUsers(Set<User> users) {
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class User extends Person implements Serializable, UserDetails {
|
||||||
@Column(name = "credential_unexpired")
|
@Column(name = "credential_unexpired")
|
||||||
private boolean credentialsNonExpired;
|
private boolean credentialsNonExpired;
|
||||||
|
|
||||||
@ManyToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
|
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
@JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"),
|
@JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"))
|
inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"))
|
||||||
private Set<Role> roles;
|
private Set<Role> roles;
|
||||||
|
@ -154,15 +154,15 @@ public class User extends Person implements Serializable, UserDetails {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRole(Role role) {
|
public void addRole(Role role) {
|
||||||
if(this.roles==null){
|
if (this.roles == null) {
|
||||||
this.roles = new HashSet<>();
|
this.roles = new HashSet<>();
|
||||||
}
|
}
|
||||||
this.roles.add(role);
|
this.roles.add(role);
|
||||||
role.getUsers().add(this);
|
role.getUsers().add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeRole(Role role){
|
public void removeRole(Role role) {
|
||||||
if(this.roles!=null){
|
if (this.roles != null) {
|
||||||
this.roles.remove(role);
|
this.roles.remove(role);
|
||||||
role.getUsers().remove(this);
|
role.getUsers().remove(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class UserService implements BaseService<User, UserDTO> {
|
||||||
User user = modelMapper.map(dto, User.class);
|
User user = modelMapper.map(dto, User.class);
|
||||||
user.setPassword(dto.getPassword());
|
user.setPassword(dto.getPassword());
|
||||||
|
|
||||||
if( dto.getRoles()!= null) {
|
if (dto.getRoles() != null) {
|
||||||
Set<Role> roles = new HashSet<>();
|
Set<Role> roles = new HashSet<>();
|
||||||
|
|
||||||
for (String role : dto.getRoles()) {
|
for (String role : dto.getRoles()) {
|
||||||
|
@ -64,7 +64,7 @@ public class UserService implements BaseService<User, UserDTO> {
|
||||||
userDto.setPassword(entity.getPassword());
|
userDto.setPassword(entity.getPassword());
|
||||||
userDto.setMatchingPassword(entity.getPassword());
|
userDto.setMatchingPassword(entity.getPassword());
|
||||||
|
|
||||||
if( entity.getRoles()!= null) {
|
if (entity.getRoles() != null) {
|
||||||
List<String> roles = new ArrayList<>();
|
List<String> roles = new ArrayList<>();
|
||||||
|
|
||||||
for (Role role : entity.getRoles()) {
|
for (Role role : entity.getRoles()) {
|
||||||
|
|
|
@ -46,6 +46,8 @@ spring.security.oauth2.client.registration.google.client-secret=${OAUTH2_GOOGLE_
|
||||||
|
|
||||||
#spring.security.oauth2.client.registration.github.client-id=${OAUTH2_GITHUB_CLIENT_ID}
|
#spring.security.oauth2.client.registration.github.client-id=${OAUTH2_GITHUB_CLIENT_ID}
|
||||||
#spring.security.oauth2.client.registration.github.client-secret=${OAUTH2_GITHUB_CLIENT_SECRET}
|
#spring.security.oauth2.client.registration.github.client-secret=${OAUTH2_GITHUB_CLIENT_SECRET}
|
||||||
|
spring.security.oauth2.client.registration.github.client-id=d3e47fc2ddd966fa4352
|
||||||
|
spring.security.oauth2.client.registration.github.client-secret=3bc0f6b8332f93076354c2a5bada2f5a05aea60d
|
||||||
|
|
||||||
|
|
||||||
spring.security.oauth2.client.registration.facebook.client-id=121189305185277
|
spring.security.oauth2.client.registration.facebook.client-id=121189305185277
|
||||||
|
|
|
@ -27,22 +27,17 @@
|
||||||
|
|
||||||
<h2 style="text-align:center">Login with Social Media</h2>
|
<h2 style="text-align:center">Login with Social Media</h2>
|
||||||
|
|
||||||
<div class="row col-md-12">
|
<div class="col-md-12 " th:each="url : ${urls}" style="text-align:center">
|
||||||
<div class="col-md-6 offset-md-3" th:each="url : ${urls}" >
|
<a th:if="${url.key == 'Google'}" th:href="${url.value}" class="btn btn-bloc" style="background-color: #dd4b39;color: white">
|
||||||
<a th:if="${url.key == 'Google'}" th:href="${url.value}" class="btn btn-bloc" style="background-color: #dd4b39;color: white">
|
<i class="fa fa-google fa-fw"></i> Login with Google
|
||||||
<i class="fa fa-google fa-fw"></i> Login with Google
|
</a>
|
||||||
</a>
|
<a th:if="${url.key == 'GitHub'}" th:href="${url.value}" class="btn btn-bloc" style="background-color: white;color: black">
|
||||||
<a th:if="${url.key == 'Twitter'}" th:href="${url.value}" class="btn btn-bloc" style="background-color: #55ACEE;color: white">
|
<i class="fa fa-github fa-fw"></i> Login with Github
|
||||||
<i class="fa fa-twitter fa-fw"></i> Login with Twitter
|
</a>
|
||||||
</a>
|
<a th:if="${url.key == 'Facebook'}" th:href="${url.value}" class="btn btn-bloc" style="background-color: #3B5998;color: white">
|
||||||
<a th:if="${url.key == 'GitHub'}" th:href="${url.value}" class="btn btn-bloc" style="background-color: white;color: black">
|
<i class="fa fa-facebook fa-fw"></i> Login with Facebook
|
||||||
<i class="fa fa-github fa-fw"></i> Login with Github
|
</a>
|
||||||
</a>
|
|
||||||
<a th:if="${url.key == 'Facebook'}" th:href="${url.value}" class="btn btn-bloc" style="background-color: #3B5998;color: white">
|
|
||||||
<i class="fa fa-facebook fa-fw"></i> Login with Facebook
|
|
||||||
</a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue