Search in sources :

Example 6 with LoginHistory

use of org.mx.comps.rbac.dal.entity.LoginHistory in project main by JohnPeng739.

the class AccountManageResource method login.

@Path("login")
@POST
public DataVO<LoginHistoryVO> login(@Context Request request, @Context Response response, AuthenticateAccountPasswordVO vo) {
    sessionDataStore.setCurrentUserCode(vo.getAccountCode());
    String accountCode = vo.getAccountCode(), password = vo.getPassword();
    boolean forced = vo.isForcedReplace();
    try {
        LoginHistory loginHistory = accountManageService.login(accountCode, password, forced);
        LoginHistoryVO loginHistoryVO = LoginHistoryVO.transform(loginHistory);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(loginHistoryVO);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error(String.format("User[%s] login fail.", vo.getAccountCode()), ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : LoginHistory(org.mx.comps.rbac.dal.entity.LoginHistory) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException)

Aggregations

LoginHistory (org.mx.comps.rbac.dal.entity.LoginHistory)6 UserInterfaceSystemErrorException (org.mx.error.UserInterfaceSystemErrorException)4 Account (org.mx.comps.rbac.dal.entity.Account)3 UserInterfaceRbacErrorException (org.mx.comps.rbac.error.UserInterfaceRbacErrorException)3 UserInterfaceException (org.mx.error.UserInterfaceException)3 PaginationDataVO (org.mx.service.rest.vo.PaginationDataVO)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 Date (java.util.Date)2 AuthenticateAround (org.mx.comps.jwt.AuthenticateAround)2 GeneralAccessor (org.mx.dal.service.GeneralAccessor)2 DataVO (org.mx.service.rest.vo.DataVO)2 Test (org.junit.Test)1 User (org.mx.comps.rbac.dal.entity.User)1 AccountManageService (org.mx.comps.rbac.service.AccountManageService)1 UserManageService (org.mx.comps.rbac.service.UserManageService)1 Pagination (org.mx.dal.Pagination)1 GeneralDictAccessor (org.mx.dal.service.GeneralDictAccessor)1