mirror of
https://github.com/sismics/docs.git
synced 2024-12-22 03:13:48 +01:00
set the admin email by env var
This commit is contained in:
parent
4aca4ad495
commit
7b89bb449d
@ -20,6 +20,11 @@ public class Constants {
|
||||
*/
|
||||
public static final String DEFAULT_ADMIN_PASSWORD = "$2a$05$6Ny3TjrW3aVAL1or2SlcR.fhuDgPKp5jp.P9fBXwVNePgeLqb4i3C";
|
||||
|
||||
/**
|
||||
* Administrator's default email.
|
||||
*/
|
||||
public static final String DEFAULT_ADMIN_EMAIL = "admin@localhost";
|
||||
|
||||
/**
|
||||
* RAM Lucene directory storage.
|
||||
*/
|
||||
@ -73,6 +78,11 @@ public class Constants {
|
||||
*/
|
||||
public static final String ADMIN_PASSWORD_INIT_ENV = "DOCS_ADMIN_PASSWORD_INIT";
|
||||
|
||||
/**
|
||||
* Initial admin password environment variable.
|
||||
*/
|
||||
public static final String ADMIN_EMAIL_INIT_ENV = "DOCS_ADMIN_EMAIL_INIT";
|
||||
|
||||
/**
|
||||
* Expiration time of the password recovery in hours.
|
||||
*/
|
||||
|
@ -94,6 +94,17 @@ public class AppContext {
|
||||
userDao.updateHashedPassword(adminUser);
|
||||
}
|
||||
}
|
||||
|
||||
// Change the admin email if needed
|
||||
String envAdminEmail = System.getenv(Constants.ADMIN_EMAIL_INIT_ENV);
|
||||
if (envAdminEmail != null) {
|
||||
UserDao userDao = new UserDao();
|
||||
User adminUser = userDao.getById("admin");
|
||||
if (Constants.DEFAULT_ADMIN_EMAIL.equals(adminUser.getEmail())) {
|
||||
adminUser.setEmail(envAdminEmail);
|
||||
userDao.update(adminUser, "admin");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +113,7 @@ public abstract class SecurityFilter implements Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
public void init(FilterConfig filterConfig) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user