Search in sources :

Example 6 with Account

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);
    }
}
Also used : Account(model.Account) User(model.User) HandleString(util.HandleString) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 7 with Account

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);
    }
}
Also used : Account(model.Account) HandleString(util.HandleString)

Example 8 with Account

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);
    }
}
Also used : Account(model.Account) User(model.User) HandleString(util.HandleString)

Example 9 with Account

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;
}
Also used : Account(model.Account) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 10 with 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();
}
Also used : Account(com.google.api.services.adsense.v2.model.Account)

Aggregations

Account (com.google.api.services.adsense.v2.model.Account)5 Account (Model.Account)4 Account (model.Account)4 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 RequestDispatcher (javax.servlet.RequestDispatcher)3 HandleString (util.HandleString)3 Courses (Model.Courses)2 IOException (java.io.IOException)2 Connection (java.sql.Connection)2 User (model.User)2 Chapter (Model.Chapter)1 Instructor (Model.Instructor)1 User (Model.User)1 FileDataStoreFactory (com.google.api.client.util.store.FileDataStoreFactory)1 Adsense (com.google.api.services.adsense.v2.Adsense)1 AdClient (com.google.api.services.adsense.v2.model.AdClient)1 AdUnit (com.google.api.services.adsense.v2.model.AdUnit)1 CustomChannel (com.google.api.services.adsense.v2.model.CustomChannel)1