mirror of https://github.com/halo-dev/halo
Fix fatal error while twice installations
parent
8c05ea1ad5
commit
9d3f409fb6
|
@ -16,24 +16,22 @@ import run.halo.app.model.entity.BaseComment;
|
||||||
import run.halo.app.model.entity.Category;
|
import run.halo.app.model.entity.Category;
|
||||||
import run.halo.app.model.entity.Post;
|
import run.halo.app.model.entity.Post;
|
||||||
import run.halo.app.model.entity.User;
|
import run.halo.app.model.entity.User;
|
||||||
import run.halo.app.model.enums.AttachmentType;
|
|
||||||
import run.halo.app.model.enums.LogType;
|
import run.halo.app.model.enums.LogType;
|
||||||
import run.halo.app.model.enums.PostStatus;
|
import run.halo.app.model.enums.PostStatus;
|
||||||
import run.halo.app.model.params.*;
|
import run.halo.app.model.params.*;
|
||||||
import run.halo.app.model.properties.*;
|
import run.halo.app.model.properties.BlogProperties;
|
||||||
|
import run.halo.app.model.properties.PrimaryProperties;
|
||||||
|
import run.halo.app.model.properties.PropertyEnum;
|
||||||
import run.halo.app.model.support.BaseResponse;
|
import run.halo.app.model.support.BaseResponse;
|
||||||
import run.halo.app.model.support.CreateCheck;
|
import run.halo.app.model.support.CreateCheck;
|
||||||
import run.halo.app.service.*;
|
import run.halo.app.service.*;
|
||||||
import run.halo.app.utils.ValidationUtils;
|
import run.halo.app.utils.ValidationUtils;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static run.halo.app.model.support.HaloConst.DEFAULT_THEME_ID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installation controller.
|
* Installation controller.
|
||||||
*
|
*
|
||||||
|
@ -196,6 +194,8 @@ public class InstallController {
|
||||||
return userService.getCurrentUser().map(user -> {
|
return userService.getCurrentUser().map(user -> {
|
||||||
// Update this user
|
// Update this user
|
||||||
installParam.update(user);
|
installParam.update(user);
|
||||||
|
// Set password manually
|
||||||
|
userService.setPassword(user, installParam.getPassword());
|
||||||
// Update user
|
// Update user
|
||||||
return userService.update(user);
|
return userService.update(user);
|
||||||
}).orElseGet(() -> userService.createBy(installParam));
|
}).orElseGet(() -> userService.createBy(installParam));
|
||||||
|
|
|
@ -125,4 +125,12 @@ public interface UserService extends CrudService<User, Integer> {
|
||||||
* @return true if the given password is match the user password; false otherwise
|
* @return true if the given password is match the user password; false otherwise
|
||||||
*/
|
*/
|
||||||
boolean passwordMatch(@NonNull User user, @Nullable String plainPassword);
|
boolean passwordMatch(@NonNull User user, @Nullable String plainPassword);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set user password.
|
||||||
|
*
|
||||||
|
* @param user user must not be null
|
||||||
|
* @param plainPassword plain password must not be blank
|
||||||
|
*/
|
||||||
|
void setPassword(@NonNull User user, @NonNull String plainPassword);
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,8 @@ public class UserServiceImpl extends AbstractCrudService<User, Integer> implemen
|
||||||
return updatedUser;
|
return updatedUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPassword(@NonNull User user, @NonNull String plainPassword) {
|
@Override
|
||||||
|
public void setPassword(@NonNull User user, @NonNull String plainPassword) {
|
||||||
Assert.notNull(user, "User must not be null");
|
Assert.notNull(user, "User must not be null");
|
||||||
Assert.hasText(plainPassword, "Plain password must not be blank");
|
Assert.hasText(plainPassword, "Plain password must not be blank");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue