public UserTO loginValidation(UserTO userTo) throws BaseAppException { boolean flag = false; String email = userTo.getEmailId(); String password = userTo.getPassword1(); Connection con; PreparedStatement psmt = null; ResultSet rs; String sql = "SELECT UserId, EmailId , Password ,FirstName , LastName , " + " RoleId FROM t_user" + " WHERE EmailId='" + email + "' AND Password ='******'" + " AND IsApproved=1"; try { con = GetConnection.getSimpleConnection(); psmt = con.prepareStatement(sql); rs = psmt.executeQuery(); if (rs.next()) { flag = true; userTo.setEmailId(rs.getString("EmailId")); // userTo.setUsername(rs.getString("FirstName") + " " + rs.getString("LastName")); userTo.setRoleId(rs.getInt("RoleId")); userTo.setUserId(rs.getInt("UserId")); // updateUnsuccessfulAttempt(email) } else { userTo = null; } } catch (SQLException sqld) { throw new RuntimeException(sqld); } finally { try { if (null != psmt) { psmt.close(); } } catch (Exception e) { throw new RuntimeException(e); } } return userTo; }
/** * populates details to SessionObj extracting the details from UserTO object * * @param userTo - UserTo Object holding the details of user * @return - Populated UserSessionInfo Object with user details */ public static UserSessionInfo populateUserDetails_ToSession(UserTO userTo, String loginType) { // Smita - 10th Aug 10 UserSessionInfo objUserInfo = new UserSessionInfo(); objUserInfo.setLoginType(loginType); objUserInfo.setEmailId(userTo.getEmailId()); objUserInfo.setFirstName(userTo.getFirstName()); objUserInfo.setLastName(userTo.getLastName()); objUserInfo.setDoneFullRegistration(userTo.isDoneFullRegistration()); objUserInfo.setRegistrationDate(userTo.getRegistrationDate()); objUserInfo.setRoleId(String.valueOf(userTo.getRoleId())); objUserInfo.setUserloginName(userTo.getUserloginID()); objUserInfo.setUserId(userTo.getUserId()); objUserInfo.setUserTo(userTo); return objUserInfo; }