MotechUserService

public interface MotechUserService

Service interface that defines APIs to retrieve and manage user details

Methods

activateUser

void activateUser(String username)

Activates user

Parameters:
  • username – of user to be activated

changeEmail

void changeEmail(String email)

Changes the e-mail address of a currenty logged user

Parameters:
  • email – a new e-mail address

changeExpiredPassword

MotechUserProfile changeExpiredPassword(String userName, String oldPassword, String newPassword)

Changes password of user with given username when user status is ‘MUST_CHANGE_PASSWORD’ and return his org.motechproject.security.domain.MotechUserProfile. The new password and the old password cannot be the same. Blocks user after crossing the failure login counter.

Parameters:
  • userName – of user
  • oldPassword – password that was used before
  • newPassword – new password for user
Throws:
Returns:

user profile after password change

changePassword

MotechUserProfile changePassword(String oldPassword, String newPassword)

Allows to change a password of a currently logged-in user.

Parameters:
  • oldPassword – An old password of currently logged user
  • newPassword – A new password for the currently logged user
Returns:

MotechUserProfile with updated user information

changePassword

MotechUserProfile changePassword(String userName, String oldPassword, String newPassword)

Changes password of user with given username and return his org.motechproject.security.domain.MotechUserProfile

Parameters:
  • userName – of user
  • oldPassword – password that was used before
  • newPassword – new password for user
Returns:

user profile after password change

deleteUser

void deleteUser(UserDto user)

Deletes given user

Parameters:
  • user – to be removed

getCurrentUser

UserDto getCurrentUser()

Returns user that is logged in current session

Returns:current user

getLocale

Locale getLocale(String userName)

Returns java.util.Locale of user with given name

Parameters:
  • userName – of user
Returns:

locale of user

getOpenIdUsers

List<MotechUserProfile> getOpenIdUsers()

Returns org.motechproject.security.domain.MotechUserProfile of users with set OpenId

Returns:list that contains users with OpenId

getRoles

List<String> getRoles(String userName)

Returns all roles of user with given name

Parameters:
  • userName – name of user
Returns:

list that contains user roles

getUser

UserDto getUser(String userName)

Returns user with given name

Parameters:
  • userName – of user
Returns:

user with given name

getUserByEmail

UserDto getUserByEmail(String email)

Returns user with given email

Parameters:
  • email – of user
Returns:

user with given email

getUsers

List<MotechUserProfile> getUsers()

Returns org.motechproject.security.domain.MotechUserProfile of all users.

Returns:list that contains profiles of all users

hasActiveMotechAdmin

boolean hasActiveMotechAdmin()

Checks if there active user with Admin role

Returns:true if user exists, otherwise false

hasEmail

boolean hasEmail(String email)

Checks if user with given email exists

Parameters:
  • email – of user
Returns:

true if user exists, false otherwise

hasUser

boolean hasUser(String username)

Checks if user with given name exists

Parameters:
  • username – of user
Returns:

true if user exists, false otherwise

register

void register(String username, String password, String email, String externalId, List<String> roles, Locale locale)

Registers new user

Parameters:
  • username – of new user
  • password – of new user
  • email – of new user
  • externalId – of new user
  • roles – list that contains roles for new user
  • locale – to be set as default for new user

register

void register(String username, String password, String email, String externalId, List<String> roles, Locale locale, UserStatus userStatus, String openId)

Registers new user

Parameters:
  • username – of new user
  • password – of new user
  • email – of new user
  • externalId – of new user
  • roles – list that contains roles for new user
  • locale – to be set as default for new user
  • userStatus – user status, org.motechproject.security.domain.UserStatus
  • openId – of new user

registerMotechAdmin

void registerMotechAdmin(String username, String password, String email, Locale locale)

A method that allows to register the first MOTECH Admin in the application. Throws java.lang.IllegalStateException when an active Admin User is already registered.

Parameters:
  • username – Username of a new user
  • password – Password of a new user
  • email – Email address of a new user
  • locale – Selected locale for the new user

retrieveUserByCredentials

MotechUserProfile retrieveUserByCredentials(String username, String password)

Returns org.motechproject.security.domain.MotechUserProfile for user with given username and password

Parameters:
  • username – of user to be returned
  • password – of user to be returned
Returns:

profile of user with given credentials

sendLoginInformation

void sendLoginInformation(String userName)

Sends login information by email using address set for user with given name

Parameters:
  • userName – name of user
Throws:

setLocale

void setLocale(Locale locale)

Sets org.motechproject.security.domain.MotechUserProfile for user in current session

Parameters:
  • locale – to be set for user

updateUserDetailsWithPassword

void updateUserDetailsWithPassword(UserDto user)

Updates user and set new password

Parameters:
  • user – to be updated

updateUserDetailsWithoutPassword

void updateUserDetailsWithoutPassword(UserDto user)

Updates user without setting new password

Parameters:
  • user – to be updated

validatePassword

void validatePassword(String password)

Checks whether the password meets requirements

Parameters:
  • password – the password to validate
Throws: