use of Model.Account in project project_internship by phamthao8383.
the class UserServlet method logInUser.
private void logInUser(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF8");
String userAccount = request.getParameter("account");
String passWord = request.getParameter("password");
Account account = accountService.CheckLogIn(userAccount, passWord);
User user = userService.getUserAccount(userAccount);
if (account.getUsername() != null) {
// Khởi tạo session
HttpSession session = request.getSession();
// Thiết lập giá trị trong session
session.setAttribute("account", account);
session.setAttribute("user", user);
System.out.println(account);
// response.sendRedirect("/index.jsp");
HomeServlet homeServlet = new HomeServlet();
homeServlet.getMaxPoint(request, response);
homeServlet.getMemberNumber(request, response);
homeServlet.getNewMember(request, response);
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/index.jsp");
dispatcher.forward(request, response);
} else // Thất bại thì quay ve lại trang login
{
request.setAttribute("sai", 1);
goLogin(request, response);
}
}
use of Model.Account in project project_internship by phamthao8383.
the class UserServlet method updatePassword.
private void updatePassword(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF8");
int idUser = Integer.parseInt(request.getParameter("idUser"));
String account = request.getParameter("nameAccount");
System.out.println(account);
String password = request.getParameter("password");
System.out.println(password);
String ps1 = request.getParameter("newPassword");
ps1 = passwordEncryption.encrypt(ps1);
String ps2 = request.getParameter("confirmPassword");
ps2 = passwordEncryption.encrypt(ps2);
Account acc = accountService.CheckLogIn(account, password);
System.out.println(acc.getUsername());
if (acc.getUsername() != null) {
accountService.editPassword(account, ps1);
System.out.println("da doi mat khau");
goGetInfo(request, response);
} else {
System.out.println("Chua doi mat khau");
request.setAttribute("checkPassword", 0);
goGetInfo(request, response);
}
}
use of Model.Account in project project_internship by phamthao8383.
the class UserServlet method createNewAccount.
private void createNewAccount(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// response.setContentType("text/html;charset=UTF8");
response.setContentType("text/html; charset=UTF-8");
request.setCharacterEncoding("UTF-8");
String nameAccount = request.getParameter("nameAccount");
// List<Account> accountList = accountService.CheckAccount(nameAccount);
// request.setAttribute("accountList", accountList);
String name = request.getParameter("name");
if (name != null && name != "") {
name = handleString.handleFont(name);
name = handleString.handleName(name);
}
String ps1 = request.getParameter("passw");
String ps2 = request.getParameter("con_passw");
ps1 = passwordEncryption.encrypt(ps1);
String email = request.getParameter("email");
String address = request.getParameter("address");
address = handleString.handleFont(address);
String phone = request.getParameter("phone");
boolean isExist = isExistAccount(nameAccount);
if (isExist) {
request.setAttribute("isExist", true);
System.out.println("Trùng tên account!!");
goLogin(request, response);
return;
//
// accountList = null;
} else {
User user = new User(name, email, phone, address, "img", nameAccount);
Account account1 = new Account(nameAccount, ps1, 2);
accountService.AddAccount(account1);
userService.addUserList(user);
request.setAttribute("isExist", false);
goLogin(request, response);
}
}
use of Model.Account in project project_internship by phamthao8383.
the class AccountRepository method CheckLogIn.
public Account CheckLogIn(String userAccount, String password) {
Account account = new Account();
try {
password = passwordEncryption.encrypt(password);
String myQuery = "SELECT `account`.username, password, role_id FROM `account` inner join user_role on `account`.username = user_role.username where `account`.username = ? and password = ?";
PreparedStatement preparedStatement = this.baseRepository.getConnection().prepareStatement(myQuery);
preparedStatement.setString(1, userAccount);
preparedStatement.setString(2, password);
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
account = new Account(rs.getString(1), rs.getString(2), rs.getInt(3));
}
} catch (SQLException e) {
e.printStackTrace();
}
return account;
}
use of Model.Account in project googleads-adsense-examples by googleads.
the class GetAccountTree method run.
/**
* Runs this sample.
*
* @param adsense AdSense service object on which to run the requests.
* @param accountId the ID for the account to be used.
* @throws Exception
*/
public static void run(Adsense adsense, String accountId) throws Exception {
System.out.println("=================================================================");
System.out.printf("Displaying AdSense account tree for %s\n", accountId);
System.out.println("=================================================================");
// Retrieve account.
Account account = adsense.accounts().get(accountId).execute();
displayTree(adsense, account, 0);
System.out.println();
}
Aggregations