Exemplo n.º 1
0
 public void changePassword(User user, String password) throws TypedSqlException {
   try {
     db.callInTransaction(
         () -> db.getDao(User.class).queryForId(user.id()).password(password).save());
   } catch (SQLException e) {
     throw new TypedSqlException(e, TypedSqlException.Type.UNKNOWN);
   }
 }
Exemplo n.º 2
0
 public User checkAuth(String name, String password) throws TypedSqlException {
   try {
     Dao<User, Long> users = db.getDao(User.class);
     List<User> userList =
         users.queryForFieldValues(Collections.<String, Object>singletonMap("name", name));
     if (!userList.isEmpty() && userList.get(0).checkPassword(password)) {
       return userList.get(0);
     }
     return null;
   } catch (SQLException e) {
     throw new TypedSqlException(e, TypedSqlException.Type.UNKNOWN);
   }
 }