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); } }
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); } }