public class UserSignupManager extends AbstractMyBatisDAO
Modifier and Type | Class and Description |
---|---|
static class |
UserSignupManager.LostPasswordError
Enumeration for different cases of lost password errors
|
static class |
UserSignupManager.TempUser
Bean representing a user sign-up request.
|
Modifier and Type | Field and Description |
---|---|
protected I18nUtils |
_i18nUtils
The i18n utils.
|
protected URIResolver |
_pageUriResolver
The page URI resolver.
|
protected PopulationContextHelper |
_populationContextHelper
The population context helper.
|
protected String |
_pwdChangeTable
The password change table.
|
protected AmetysObjectResolver |
_resolver
The ametys object resolver.
|
protected SiteConfigurationExtensionPoint |
_siteConf
The site configuration extension point.
|
protected SiteManager |
_siteManager
The site manager.
|
protected String |
_tempUsersTable
The temporary users table.
|
protected URIResolverExtensionPoint |
_uriResolverEP
The ametys object resolver.
|
protected UserManager |
_userManager
The user manager.
|
protected UserPopulationDAO |
_userPopulationDAO
The DAO for user populations
|
protected UserSignUpConfiguration |
_userSignUpConfiguration
The user sign up configuration
|
static String |
ROLE
The component role.
|
static int |
SIGNUP_ERROR
Token return code: undefined error.
|
static int |
SIGNUP_ERROR_TEMP_EMAIL_ALREADY_EXISTS
Temporary signup return code: a user tried to sign-up but the e-mail already exists in the temporary table.
|
static int |
SIGNUP_ERROR_USER_ALREADY_EXISTS
Temporary signup return code: a user tried to sign-up but the FO UsersManager already possesses a user with this e-mail as login.
|
static int |
SIGNUP_NO_ERROR
Return code which indicates no error.
|
static int |
SIGNUP_RESET_ERROR_EMAIL_UNKNOWN
Reset token return code: a user asked for a new token, but no subscription request can be found with this e-mail.
|
static int |
SIGNUP_TOKEN_EXPIRED
Token return code: a user provided a token, but it isn't valid anymore.
|
static int |
SIGNUP_TOKEN_UNKNOWN
Token return code: a user provided a token, but it doesn't exist.
|
_manager
Constructor and Description |
---|
UserSignupManager() |
Modifier and Type | Method and Description |
---|---|
void |
additionalSignupOperations(User createdUser,
Multimap<String,I18nizableText> errors)
Process additional operations after creation of user
|
protected void |
addPasswordToken(String siteName,
String login,
String token,
String population)
Create a user password change request in the database.
|
protected int |
addTemporaryUser(String siteName,
String email,
String token,
String population,
String userDirectoryId)
Create a user sign-up request ("temporary" user) in the database.
|
int |
changeUserPassword(String siteName,
String login,
String token,
String newPassword,
String population)
Change the user password.
|
int |
checkPasswordToken(String siteName,
String login,
String token,
String population)
Check the password change request token.
|
protected void |
checkPublicSignup(String siteName)
Verify that public sign-up is allowed.
|
int |
checkToken(String siteName,
String email,
String token,
String population,
String userDirectoryId)
Check the sign-up request token.
|
void |
configure(Configuration configuration) |
Content |
getGTUContent(ZoneItem zoneItem)
Get the GTU content
Returns null if not found or empty
|
Page |
getGTUPage(ZoneItem zoneItem)
Get the GTU page
Returns null if not found or empty
|
Page |
getPwdChangePage(String siteName,
String language)
Get the password change page in a given site and sitemap.
|
AmetysObjectIterable<Page> |
getPwdChangePages(String siteName,
String language)
Get all the pages tagged "password change".
|
Page |
getSignupPage(String siteName,
String language)
Get the sign-up page in a given site and sitemap.
If more than one page are tagged "sign-up", return the first. |
AmetysObjectIterable<Page> |
getSignupPages(String siteName,
String language)
Get all the pages tagged "sign-up".
|
Content |
getSuccessContent(ZoneItem zoneItem)
Get the success content
Returns null if not found or empty
|
Page |
getSuccessPage(ZoneItem zoneItem)
Get the GTU page
Returns null if not found or empty
|
protected UserSignupManager.TempUser |
getTempUser(String siteName,
String email,
String population,
String userDirectoryId)
Get a temporary user from his site name and e-mail.
|
protected UserSignupManager.TempUser |
getTempUser(String siteName,
String email,
String token,
String population,
String userDirectoryId)
Get a temporary user from his site name, e-mail and/or token.
|
String |
getToken(String siteName,
String email,
String population,
String userDirectoryId)
Get a token for temp user
|
boolean |
isPublicSignupAllowed(String siteName)
Test if public signup is allowed in a site.
|
void |
removeExpiredPasswordTokens()
Remove the expired change password request tokens.
|
void |
removeExpiredTokens()
Remove the expired sign-up request tokens.
|
protected void |
removePasswordToken(String siteName,
String login,
String token,
String population)
Remove the password change request.
|
protected void |
removeTempUser(String siteName,
String email,
String token,
String population,
String userDirectoryId)
Remove the temporary .
|
UserSignupManager.LostPasswordError |
resetPassword(String siteName,
String language,
String loginOrEmail,
String populationId)
Create a reset password request and send a confirmation e-mail.
|
int |
resetTempSignup(String siteName,
String language,
String email,
String population,
String userDirectoryId)
Reset a sign-up request: generate a new token and re-send the confirmation e-mail.
|
protected void |
sendResetPasswordMail(String siteName,
String language,
User user,
String token)
Send a sign-up confirmation link by e-mail.
|
protected void |
sendSignupConfirmMail(String siteName,
String language,
String email,
String token)
Send a sign-up confirmation link by e-mail.
|
protected void |
sendSignupValidatedMail(String siteName,
String language,
User user)
Send a sign-up confirmation link by e-mail.
|
void |
service(ServiceManager serviceManager) |
int |
signup(String siteName,
String language,
String firstname,
String lastname,
String email,
String token,
String password,
String population,
String userDirectoryId,
Multimap<String,I18nizableText> errors)
Create the user in the FO UsersManager from his temporary request.
|
int |
temporarySignup(String siteName,
String language,
String email,
String population,
String userDirectoryId)
Validate and store a sign-up request and send a confirmation e-mail.
|
int |
temporarySignup(String siteName,
String language,
String email,
String population,
String userDirectoryId,
boolean sendMail)
Validate and store a sign-up request and send a confirmation e-mail.
|
protected void |
updateTempToken(String siteName,
String email,
String newToken,
String population,
String userDirectoryId)
Update the sign-up request token: reset the date and set a new token.
|
boolean |
userExists(String email,
String siteName)
Tests if the user already exists in the populations
|
Map<String,Errors> |
validate(String siteName,
String email,
Map<String,String> additionalValues)
Validate the user subscription data.
|
Map<String,Errors> |
validatePassword(String siteName,
String password,
String login,
String population)
Validate the user password.
|
void |
validationBeforeSignup(Multimap<String,I18nizableText> errors)
Do some validation before signup
|
_configureDatasource, _getDataSourceId, _getMyBatisConfiguration, contextualize, getSession, getSession, reload, setPluginInfo
getLogger, setLogger
public static final int SIGNUP_NO_ERROR
public static final int SIGNUP_ERROR_TEMP_EMAIL_ALREADY_EXISTS
public static final int SIGNUP_ERROR_USER_ALREADY_EXISTS
public static final int SIGNUP_TOKEN_UNKNOWN
public static final int SIGNUP_TOKEN_EXPIRED
public static final int SIGNUP_ERROR
public static final int SIGNUP_RESET_ERROR_EMAIL_UNKNOWN
protected UserManager _userManager
protected UserPopulationDAO _userPopulationDAO
protected SiteManager _siteManager
protected SiteConfigurationExtensionPoint _siteConf
protected AmetysObjectResolver _resolver
protected URIResolverExtensionPoint _uriResolverEP
protected URIResolver _pageUriResolver
protected I18nUtils _i18nUtils
protected UserSignUpConfiguration _userSignUpConfiguration
protected String _tempUsersTable
protected String _pwdChangeTable
protected PopulationContextHelper _populationContextHelper
public UserSignupManager()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
service
in class AbstractMyBatisDAO
ServiceException
public void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
configure
in class AbstractMyBatisDAO
ConfigurationException
public boolean isPublicSignupAllowed(String siteName)
siteName
- the site to test.public Page getSignupPage(String siteName, String language)
siteName
- the site name.language
- the sitemap name.public AmetysObjectIterable<Page> getSignupPages(String siteName, String language)
siteName
- the site name.language
- the sitemap name.public Page getPwdChangePage(String siteName, String language)
siteName
- the site name.language
- the sitemap name.public Page getGTUPage(ZoneItem zoneItem)
zoneItem
- the zone itempublic Content getGTUContent(ZoneItem zoneItem)
zoneItem
- the zone itempublic Page getSuccessPage(ZoneItem zoneItem)
zoneItem
- the zone itempublic Content getSuccessContent(ZoneItem zoneItem)
zoneItem
- the zone itempublic AmetysObjectIterable<Page> getPwdChangePages(String siteName, String language)
siteName
- the site name.language
- the sitemap name.public boolean userExists(String email, String siteName) throws UserManagementException
email
- the e-mail to test.siteName
- The site nameUserManagementException
- if an error occurs.public Map<String,Errors> validate(String siteName, String email, Map<String,String> additionalValues) throws UserManagementException
siteName
- the site name.email
- the user e-mail.additionalValues
- the additional user values.UserManagementException
- if an error occurs.public Map<String,Errors> validatePassword(String siteName, String password, String login, String population) throws UserManagementException
siteName
- the site name.password
- the password to validate.login
- the login of the userpopulation
- The id of the populationUserManagementException
- if an error occurs.public int temporarySignup(String siteName, String language, String email, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.language
- the sitemap name.email
- the user e-mail address.population
- the populationuserDirectoryId
- the id of the user directory of the populationUserManagementException
- if an error occurs.public int temporarySignup(String siteName, String language, String email, String population, String userDirectoryId, boolean sendMail) throws UserManagementException
siteName
- the site name.language
- the sitemap name.email
- the user e-mail address.population
- the populationuserDirectoryId
- the id of the user directory of the populationsendMail
- Set to false to not send mail at end of processUserManagementException
- if an error occurs.public String getToken(String siteName, String email, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- the user e-mail address.population
- The id of the populationuserDirectoryId
- The id of the user directory of the populationUserManagementException
- if an error occurs.public int resetTempSignup(String siteName, String language, String email, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.language
- the sitemap name.email
- the user e-mail address.population
- The id of the populationuserDirectoryId
- The id of the user directory of the populationUserManagementException
- if an error occurs.public int signup(String siteName, String language, String firstname, String lastname, String email, String token, String password, String population, String userDirectoryId, Multimap<String,I18nizableText> errors) throws UserManagementException
siteName
- the site name.language
- the current languagefirstname
- the user firstnamelastname
- the user lastnameemail
- the user e-mail address.token
- the request token.password
- the user password.population
- The id of the populationuserDirectoryId
- The id of the user directory of the populationerrors
- the errorsUserManagementException
- if an error occurs.public void validationBeforeSignup(Multimap<String,I18nizableText> errors)
errors
- the map of errors to fill in cause of errors during validationpublic void additionalSignupOperations(User createdUser, Multimap<String,I18nizableText> errors) throws UserManagementException
createdUser
- the created usererrors
- the map of errors to fill in case of errors during additional operationsUserManagementException
- if an error occurs.public UserSignupManager.LostPasswordError resetPassword(String siteName, String language, String loginOrEmail, String populationId) throws UserManagementException
siteName
- the site name.language
- the sitemap name.loginOrEmail
- the user login or email.populationId
- the populationUserManagementException
- if an error occurs.public int changeUserPassword(String siteName, String login, String token, String newPassword, String population) throws UserManagementException
siteName
- the site name.login
- the user login.token
- the password change request token.newPassword
- the new password.population
- the populationUserManagementException
- if an error occurs.public int checkToken(String siteName, String email, String token, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- the user e-mail.token
- the sign-up request token.population
- The id of the populationuserDirectoryId
- The id of the user directory of the populationUserManagementException
- if an error occurs.public int checkPasswordToken(String siteName, String login, String token, String population) throws UserManagementException
siteName
- the site name.login
- the user login.token
- the password change request token.population
- the populationUserManagementException
- if an error occurs.public void removeExpiredTokens() throws UserManagementException
UserManagementException
- if an error occurs.public void removeExpiredPasswordTokens() throws UserManagementException
UserManagementException
- if an error occurs.protected void checkPublicSignup(String siteName) throws UserManagementException
siteName
- the site name.UserManagementException
- if public sign-up is not enabled.protected int addTemporaryUser(String siteName, String email, String token, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- the user e-mail.token
- the generated token.population
- the populationuserDirectoryId
- the id of the user directory of the populationUserManagementException
- if an error occurs.protected void sendSignupConfirmMail(String siteName, String language, String email, String token) throws UserManagementException
siteName
- the site name.language
- the e-mail language.email
- the user e-mail.token
- the generated token.UserManagementException
- if an error occurs.protected void sendSignupValidatedMail(String siteName, String language, User user) throws UserManagementException
siteName
- the site name.language
- the e-mail language.user
- the created userUserManagementException
- if an error occurs.protected void updateTempToken(String siteName, String email, String newToken, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- the user e-mail.newToken
- the new token.population
- The id of the populationuserDirectoryId
- The id of the user directory of the populationUserManagementException
- if an error occurs.protected void addPasswordToken(String siteName, String login, String token, String population) throws UserManagementException
siteName
- the site name.login
- the user login.token
- the generated token.population
- the populationUserManagementException
- if an error occurs.protected UserSignupManager.TempUser getTempUser(String siteName, String email, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- The temporary user e-mail. Cannot be null.population
- the populationuserDirectoryId
- the id of the user directory of the populationUserManagementException
- if an error occurs.protected UserSignupManager.TempUser getTempUser(String siteName, String email, String token, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- The temporary user e-mail. Can be null.token
- The temporary user token. Can be null.population
- the population. Must be not null if email is not nulluserDirectoryId
- the id of the user directory of the population. Must be not null if email is not nullUserManagementException
- if an error occurs.protected void removeTempUser(String siteName, String email, String token, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- the user e-mail address.token
- the request token.population
- the populationuserDirectoryId
- the id of the user directory of the populationUserManagementException
- if an error occurs.protected void removePasswordToken(String siteName, String login, String token, String population) throws UserManagementException
siteName
- the site name.login
- the user login.token
- the request token.population
- the populationUserManagementException
- if an error occurs.protected void sendResetPasswordMail(String siteName, String language, User user, String token) throws UserManagementException
siteName
- the site name.language
- the e-mail language.user
- the user object.token
- the generated token.UserManagementException
- if an error occurs.