mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
env var for admin password expected hashed
This commit is contained in:
parent
0903c03a29
commit
66d331ddb8
@ -148,6 +148,26 @@ public class UserDao {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the hashed password silently.
|
||||||
|
*
|
||||||
|
* @param user User to update
|
||||||
|
* @return Updated user
|
||||||
|
*/
|
||||||
|
public User updateHashedPassword(User user) {
|
||||||
|
EntityManager em = ThreadLocalContext.get().getEntityManager();
|
||||||
|
|
||||||
|
// Get the user
|
||||||
|
Query q = em.createQuery("select u from User u where u.id = :id and u.deleteDate is null");
|
||||||
|
q.setParameter("id", user.getId());
|
||||||
|
User userFromDb = (User) q.getSingleResult();
|
||||||
|
|
||||||
|
// Update the user
|
||||||
|
userFromDb.setPassword(user.getPassword());
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a user by its ID.
|
* Gets a user by its ID.
|
||||||
*
|
*
|
||||||
|
@ -79,7 +79,7 @@ public class AppContext {
|
|||||||
User adminUser = userDao.getById("admin");
|
User adminUser = userDao.getById("admin");
|
||||||
if (Constants.DEFAULT_ADMIN_PASSWORD.equals(adminUser.getPassword())) {
|
if (Constants.DEFAULT_ADMIN_PASSWORD.equals(adminUser.getPassword())) {
|
||||||
adminUser.setPassword(envAdminPassword);
|
adminUser.setPassword(envAdminPassword);
|
||||||
userDao.updatePassword(adminUser, null);
|
userDao.updateHashedPassword(adminUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user